home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / scanbat.zip / TUTR.DOC < prev    next >
Text File  |  1989-10-02  |  110KB  |  2,436 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.             B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  9.  
  10.                          (C)opyright 1989 Paul Scanlon
  11.  
  12.  
  13.                      Brought to you by Scanlon Enterprises
  14.                                        38354 17th St E # C
  15.                                        Palmdale, CA  93550
  16.  
  17.  
  18.  
  19.  
  20.        This  tutorial  is NOT an attempt to replace the  MS/PC-DOS  user
  21.        manual.  This is an attempt to give instruction on Batch files in
  22.        general,  and will advance to full and detailed  explanations  of
  23.        using  our  own  utilities (SEBFU).  We hope that  this  will  be
  24.        informative and useful to you.
  25.  
  26.  
  27.        The material herein is written for Dos versions 2.x and above, if
  28.        you  are  using Dos 1.x many of the features  described  may  NOT
  29.        function  with your system. If you are using a Dos version  lower
  30.        than  2.x, we heartily suggest that you upgrade. As a  matter  of
  31.        fact we suggest going to at least 3.2 .  Dos has versions ranging
  32.        all the way thru 4.0 .
  33.  
  34.  
  35.        This  document is copyrighted and may not be copied or  otherwise
  36.        reproduced  without written consent by the author. Doing so  will
  37.        place the duplicator in direct violation of the Federal copyright
  38.        protection laws, and prosecution will be in federal courts.
  39.  
  40.  
  41.        If you find this document and our utilities useful and intend  to
  42.        use  them  on a regular basis, you are required to  register  the
  43.        utilities.   For  details on registration read  the  REGISTER.DOC
  44.        file. Our fee for the utilities is only $19.50 (single user).  We
  45.        feel  that this price is very fair (and reasonable) and  we  will
  46.        support  you.  Our  support  includes  answering  any   questions
  47.        regarding  Batch  files in general. Also, we want  to  know  what
  48.        improvements to make, or what additional commands you would like.
  49.  
  50.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  51.  
  52.           by Scanlon Enterprises                         Page 2
  53.  
  54.  
  55.        We  will  begin  our discussion with a quick talk  about  Dos  in
  56.        general. DOS, when used herein will refer to both PC-DOS and  MS-
  57.        DOS. What is DOS ? DOS stands for Disk Operation System.  Without
  58.        Dos, you couldn't easily save and retrieve data from disk drives.
  59.  
  60.        Everything  you enter at the DOS prompt is considered a  command.
  61.        Commands  are either internal or external. By internal,  we  mean
  62.        that  the  command  will function if you have  a  formatted  disk
  63.        (formatted using the /S option) which has the invisible files for
  64.        DOS and the visible file COMMAND.COM .  External commands are any
  65.        legal  file  name with extensions of EXE, COM  and  BAT.  Indeed,
  66.        COMMAND.COM itself is a command !
  67.  
  68.        How  does  this relate to batch files ?  Well, a  batch  file  is
  69.        nothing  more  (nor less) than a file consisting of one  or  more
  70.        lines  of commands. This is where the term batch file  came  from
  71.        (for  batch processing). In other words, a batch file  is  simply
  72.        read by DOS, and each line therein is executed (if the line is  a
  73.        command).  Batch  files  are very useful, and  can  perform  many
  74.        functions  automatically,  thus  saving the user  much  time  and
  75.        effort  in  entering  key strokes  for  each  function  (command)
  76.        separately.  One  of the best know batch files  is  AUTOEXEC.BAT,
  77.        which performs setup information when you system is first booted.
  78.  
  79.        We will now give a little more detail about Dos and its use.  For
  80.        purposes of our discussion, we suggest that you make a  formatted
  81.        disk using the /S option. To do this, enter :
  82.  
  83.                                                FORMAT A: /S
  84.  
  85.        Where  A is the 1st floppy drive (in some cases the only one)  on
  86.        your  system. If you need more information on formatting a  disk,
  87.        please consult your Dos manual.
  88.  
  89.        Also,  we suggest that you print this document, so that  you  can
  90.        read  it while performing many of the suggested  experiments  and
  91.        tests.   If you don't have a printer, we will send you a  printed
  92.        copy for a small fee ($5), just mail us a check to the address on
  93.        page 1, and we will Airmail out a copy.
  94.  
  95.        Now,  if you have that disk ready, place it into drive A of  your
  96.        system,  and  press the keys <CTRL>,<ALT> and <DEL> at  the  same
  97.        time.  This will reboot your system.  If you formatted  the  disk
  98.        correctly, you should see a message similar to the following.
  99.  
  100.        Current date is Fri. 3-03-1980
  101.        Enter new date (mm-dd-yy):_
  102.  
  103.        Press enter now, and you will then have the additional lines :
  104.  
  105.        Current time is 9:37:12.05
  106.        Enter new time:_
  107.  
  108.        Please  press  enter again (for our purposes, we don't  need  the
  109.        correct time and date.
  110.  
  111.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  112.  
  113.           by Scanlon Enterprises                         Page 3
  114.  
  115.  
  116.  
  117.        Your display should now be similar to the following :
  118.  
  119.        Current date is Fri. 3-03-1980
  120.        Enter new date (mm-dd-yy):
  121.        Current time is 9:37:12.05
  122.        Enter new time:
  123.  
  124.  
  125.        Microsoft (R)  MS-DOS (R)   Version  3.20
  126.                       (C) Copyright Microsoft Corp 1981-1987
  127.  
  128.  
  129.        A>_
  130.  
  131.        Of  course  your time and dates and perhaps Dos version  will  be
  132.        different.  Also  if you are using PC-DOS, the  copyright  notice
  133.        will  be  different. Here we are, with a blank disk  (except  for
  134.        COMMAND.COM).  Verify this, type DIR.  You should have  a  screen
  135.        similar to the following :
  136.  
  137.  
  138.        Current date is Fri  3-03-1980
  139.        Enter new date (mm-dd-yy):
  140.        Current time is 9:37:12.05
  141.        Enter new time:
  142.  
  143.  
  144.        Microsoft (R) MS-DOS (R)   Version 3.20
  145.                      (C) Copyright Microsoft Corp 1981-1987
  146.  
  147.  
  148.        A>dir
  149.  
  150.         Volume in drive A has no label
  151.         Directory of  A:\
  152.  
  153.        COMMAND  COM    25276   3-03-1980   9:38a
  154.                1 File(s)    283648 bytes free
  155.  
  156.        A>_
  157.  
  158.        Notice  that  the line containing the word Volume ends  with  the
  159.        words no label.  This means we didn't format the disk with the /V
  160.        option  (read  your Dos manual). If the disk had  been  formatted
  161.        with  that  option, the line would contain the  label  name.  The
  162.        second line gives us the path of the directory, in this case, A:\
  163.        which  is the root directory of drive (the only  directory).  And
  164.        finally  the list of files (only one in this case).  The list  of
  165.        files  has  the  file name (note the lack of  the  decimal  point
  166.        separator  between the 8 character name and the extension).  This
  167.        line  contains the file name (COMMAND.COM), the size of the  file
  168.        in bytes (25276), the date the file was created (not  necessarily
  169.        the  date you formatted the disk) and finally the time  the  file
  170.        was  created.  The last line gives the total number of  files  in
  171.        the list, along with the number of bytes free on the disk.
  172.  
  173.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  174.  
  175.           by Scanlon Enterprises                         Page 4
  176.  
  177.  
  178.  
  179.  
  180.        What  does  all  this  mean to you ?  Well  first  off,  we  have
  181.        executed a command (DIR or dir) !  And we know that this  command
  182.        is internal, because there isn't a file on the disk with the name
  183.        DIR.COM  or  DIR.EXE  or even DIR.BAT .  You  ask,  can  the  DIR
  184.        command be used in a batch file ?  You betcha !  A batch file can
  185.        execute  any command, be it an internal or external.  And  again,
  186.        the  difference  between external commands and internal  ones  is
  187.        that  external commands require a file with the name  used.  IE..
  188.        when  you formatted the disk, you used the command  FORMAT.   You
  189.        will find that FORMAT is a file with the extension COM. And  yes,
  190.        format can be used from a batch file !
  191.  
  192.        In fact, one of the batch files we will create, uses FORMAT.  Why
  193.        are  we spending so much time here ?  Well, we want to make  sure
  194.        you  understand  which  commands  are  internal  and  which   are
  195.        external.  Here is a list of all of the internal commands :
  196.  
  197.        BREAK       CHDIR (CD)  CLS       COPY      DATE      DEL (ERASE)
  198.        DIR         ECHO        ERRORLEVEL          EXIST     EXIT
  199.        FOR         GOTO        IF        MKDIR (MD)          PATH
  200.        NOT         PAUSE       PROMPT    REM       RENAME (REN)
  201.        RMDIR (RD)  SET         SHIFT     TIME      TYPE      VER
  202.        VERIFY      VOL
  203.  
  204.        And  in Dos 3.3 we also have CALL and CHCP . Since these are  new
  205.        to  Dos,  we won't be discussing them here, other  than  a  brief
  206.        comment or two.
  207.  
  208.        Some of the above commands can only be used from batch files. One
  209.        good example is the ERRORLEVEL command.  The ERRORLEVEL is really
  210.        more  of  a flag than anything, and is a test of how  a  previous
  211.        command executed.  Many programs don't set the ERRORLEVEL for use
  212.        in  batch files, but you will find that our Batch File  Utilities
  213.        make extensive use of it.  More about ERRORLEVEL later.
  214.  
  215.        Now,  let's create our first batch file.  We are going to  create
  216.        an  AUTOEXEC.BAT  file.   At this point, you should  have  a  Dos
  217.        prompt of A>_ sitting in front of you.  Enter the following :
  218.  
  219.        COPY CON AUTOEXEC.BAT
  220.  
  221.        Your screen should now have the line :
  222.  
  223.        A>COPY CON AUTOEXEC.BAT_
  224.  
  225.        Press enter.  Your cursor will now move to the next line, but you
  226.        won't have a prompt.  Don't get nervous, what we've done, is  ask
  227.        Dos  to copy a file, in this case the source file is the  console
  228.        (or  keyboard),  the destination is the file AUTOEXEC.BAT  .   At
  229.        this  time,  we aren't going to put much into the file,  so  just
  230.        press  the space bar once. The cursor will move to the right  one
  231.        space.   Now, hold down the control key (CNTL) and press the  'Z'
  232.        key. You'll see a ^Z on the display. Now press enter. You  should
  233.        get  your Dos prompt back (A>_) .
  234.  
  235.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  236.  
  237.           by Scanlon Enterprises                         Page 5
  238.  
  239.  
  240.  
  241.        If  you  don't get your prompt back, try pressing the  enter  key
  242.        again.   If you still don't have it, look at the screen.  Do  you
  243.        have the characters ^Z ?  If not, press and hold the control  key
  244.        then  press  the 'Z ' key again.  Finally press  enter.   If  you
  245.        still  don't have the prompt, reboot your system, and start  this
  246.        section  over.  If you just can't do it, let us know !   And  for
  247.        now, just precede with the rest of this instruction.
  248.  
  249.        We  have  now created a file called AUTOEXEC.BAT.  It's  time  to
  250.        reboot your computer again.  Leave the disk in drive A and  press
  251.        <Ctrl>  <Alt> <Del> (at the same time). Your system will  reboot.
  252.        This  time,  you  will not be greeted with all  of  the  previous
  253.        information.   You  won't be prompted for the time or  date,  and
  254.        your screen will look similar to the following :
  255.  
  256.        A>
  257.        A>
  258.  
  259.        What, no messages ? !!  Yep, you got it.  By creating a file with
  260.        a  single space in it, we managed to by pass all those  messages.
  261.        What  good  is that ?  Well, if you have an AT class  machine  or
  262.        some  other type that has a built in time clock, you can by  pass
  263.        those  opening  messages and get on to what you want to  do.   Of
  264.        course, there are much more important uses for AUTOEXEC.BAT  than
  265.        this.  For instance, what about that silly prompt ?  Can that  be
  266.        changed ?  The answer is yes.
  267.  
  268.  
  269.        How do you do that ?  Well we use the PROMPT command of course  !
  270.        OK, enter the following on your command line. (A brief note, when
  271.        ever  we  say command line we are referring to the  current  line
  272.        with the Dos prompt on it.) Enter PROMPT $g  and press enter.
  273.  
  274.        Your display should have :
  275.  
  276.        A>PROMPT $g
  277.  
  278.        >_
  279.  
  280.        Whoops, we lost the drive letter, how do we know where we are ?
  281.  
  282.        Enter 'dir' and press enter   (>dir_<enter>)
  283.  
  284.        Your  directory  list will now contain 2 files,  COMMAND.COM  and
  285.        AUTOEXEC.BAT .  Well that's one way to find out what drive you're
  286.        on.  Back to the prompt command.  Enter PROMPT $P$G
  287.  
  288.        >PROMPT $P$G_
  289.  
  290.        Now press enter. Look what you got now.
  291.  
  292.        A:\>_
  293.  
  294.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  295.  
  296.           by Scanlon Enterprises                         Page 6
  297.  
  298.  
  299.  
  300.        What  we've done is tell Dos to display a prompt using  the  path
  301.        (in  this case A:\ is the path) and the greater than symbol.  For
  302.        more details on use of the PROMPT command, refer to your Dos user
  303.        manual. It is not our intent to teach you about Dos, but we  will
  304.        be giving some information as it pertains to batch files.
  305.  
  306.        Earlier  we mention that AT's and similar machines don't  require
  307.        the user to enter the time and date when their system is  booted.
  308.        This  also applies to those who have PC's with real  time  clocks
  309.        added to them. Usually these systems have a command similar to :
  310.  
  311.        TIMER /I
  312.  
  313.        appended  to  the AUTOEXEC batch file. This command when  run  at
  314.        boot  time sets the Dos time and date from the real  time  clock.
  315.        For those of you who have this, we refer you to the documentation
  316.        which came with your system or when you had the clock installed.
  317.  
  318.        We  will  cover this topic later on, and show you  where  in  the
  319.        AUTOEXEC  batch  file  to place your command for  the  real  time
  320.        clock.  For  those who have AT's and 386 machines, the  time  and
  321.        date is automatically set at boot time from your Rom Bios.
  322.  
  323.        OK, now let's add the PROMPT command to our AUTOEXEC batch  file.
  324.        At  the  command line, enter  COPY CON AUTOEXEC.BAT   then  press
  325.        enter.  You  won't have a Dos prompt, the cursor will be  on  the
  326.        next line, IE....
  327.  
  328.        A:\>COPY CON AUTOEXEC.BAT
  329.        _
  330.  
  331.        Enter  the  string 'PROMPT $P$G' and press enter.   Your  display
  332.        will now have these lines :
  333.  
  334.        A:\>COPY CON AUTOEXEC.BAT
  335.        PROMPT $P$G
  336.        _
  337.  
  338.        Press  and hold the control key, then press the letter 'Z', a  ^Z
  339.        will  appear  on the screen, release the control  key  and  press
  340.        enter. You should get the message  '1 file copied', and then your
  341.        Dos prompt on the next line.
  342.  
  343.        A:\>COPY CON AUTOEXEC.BAT
  344.        PROMPT $P$G
  345.        ^Z
  346.                1 File(s) copied
  347.  
  348.        A:\>_
  349.  
  350.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  351.  
  352.           by Scanlon Enterprises                         Page 7
  353.  
  354.  
  355.  
  356.        Reboot  your  system. This time when it boots, you will  get  the
  357.        following screen.
  358.  
  359.        A>PROMPT $P$G
  360.  
  361.        A:\>
  362.        A:\>_
  363.  
  364.        Now why did the line 'PROMPT $P$G' show up ?  A little more about
  365.        Dos  is in order. Whenever Dos runs a batch file, the  Echo  mode
  366.        will  be on. What this means, is that all commands in  the  batch
  367.        file  will  not  only execute, but will also  be  echoed  to  the
  368.        display.  What  can we do about it ?  Let's modify  our  AUTOEXEC
  369.        batch file again.  Enter the command line 'COPY CON AUTOEXEC.BAT'
  370.        and  press enter. On the first line, enter 'ECHO OFF'  and  press
  371.        enter.  The next line, enter 'PROMPT $P$G' and enter.  Now  press
  372.        and  hold  the  control key, press the letter  'Z',  release  the
  373.        control  key  and  press enter. You should  now  have  a  display
  374.        similar to this :
  375.  
  376.        A:\>COPY CON AUTOEXEC.BAT
  377.        ECHO OFF
  378.        PROMPT $P$G
  379.        ^Z
  380.                1 File(s) copied
  381.  
  382.        A:\>_
  383.  
  384.        OK,  reboot  again.  If all this booting is making  you  nervous,
  385.        don't  worry, we won't be doing it much longer.  We just want  to
  386.        give  you an idea of what happens when ever you change  something
  387.        in the AUTOEXEC batch file.
  388.  
  389.  
  390.        After rebooting, your display should look something like :
  391.  
  392.        A>ECHO OFF
  393.  
  394.        A:\>
  395.        A:\>_
  396.  
  397.        We still have the command echo on the display. Let's now go  thru
  398.        and see exactly what we did.  The first line is the echo command,
  399.        followed by the switch OFF.  What this means, is that if the echo
  400.        command  is  followed by a single word ON or OFF, then  the  echo
  401.        mode  will be switched on or off. Just to get an idea of what  we
  402.        are  talking  about, at the command line enter 'echo  Hello,  I'm
  403.        here.' and press enter. You will see:
  404.  
  405.        A:\>echo Hello, I'm here.
  406.        Hello, I'm here.
  407.  
  408.        A:\>_
  409.  
  410.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  411.  
  412.           by Scanlon Enterprises                         Page 8
  413.  
  414.  
  415.  
  416.        One  noticeable  quirk of the echo command with the  on  and  off
  417.        switches, is that if at the command line you enter ECHO OFF,  you
  418.        will  lose you prompt. Try it. To regain the prompt,  just  enter
  419.        ECHO ON at the next line (where ever your cursor is).
  420.  
  421.        Onward.  Well, we've now learned 2 commands we can use  in  batch
  422.        files.   Although  we  are using the AUTOEXEC.BAT  file  for  our
  423.        purposes, these same commands can work in any file.  IE, try  the
  424.        following command sequence.
  425.  
  426.        A:\>COPY CON TEST.BAT
  427.        ECHO OFF
  428.        CLS
  429.        PROMPT $P$G
  430.        ^Z [ENTER]
  431.  
  432.        A:\>_
  433.  
  434.        Enter  Dir at the Dos prompt. You will now have 3  files  listed,
  435.        COMMAND.COM,  AUTOEXEC.BAT  and TEST.BAT. Now type  TEST  on  the
  436.        command line. Your display should clear and your Dos prompt  will
  437.        be at the top of the screen. We've added a new command, CLS.  The
  438.        CLS  command clears the screen, and positions the cursor  to  the
  439.        very top of the display.
  440.  
  441.        Let's  talk  a little more about Dos. If we were to  keep  adding
  442.        files  to our disk (like we're doing), we would soon have a  full
  443.        disk.  MS-DOS allows us to have only a little over 100  files  in
  444.        any directory.
  445.  
  446.        What is a directory ?  A directory can be considered much like  a
  447.        file  cabinet,  which  has many doors (or  drawers),  which  when
  448.        opened,  presents either more doors or some files. In this  case,
  449.        the files are your programs (like AUTOEXEC, TEST and COMMAND),and
  450.        the  doors  are directories. The root directory is  the  starting
  451.        point  for all other directories, much like the lobby of a  large
  452.        building.
  453.  
  454.        You  can  precede thru directories in 2 directions, up  or  down.
  455.        When going up, you are moving away from the root directory,  when
  456.        going  down,  you are moving toward the root directory.  You  can
  457.        view this motion much like an elevator ride. Take the elevator up
  458.        and get off at a floor to see what's there.
  459.  
  460.        Now that we've given you some input on what a directory is, let's
  461.        make one. To make a directory, Dos has the command MKDIR, or  the
  462.        2  character  version  MD,  Dos will perform  the  task  (make  a
  463.        directory) no matter which you enter. Enter 'MD BATCH' and  press
  464.        enter. All that appears to have happened is that you've gotten  a
  465.        new Dos prompt. Enter 'dir' at the command line. You should  have
  466.        a list similar to the following :
  467.  
  468.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  469.  
  470.           by Scanlon Enterprises                         Page 9
  471.  
  472.  
  473.  
  474.        A:\>dir
  475.  
  476.         Volume in drive A has no label
  477.         Directory of  A:\
  478.  
  479.        COMMAND  COM    25276   7-24-87   12:00a
  480.        AUTOEXEC BAT       13   3-03-89    9:45a
  481.        TEST     BAT       28   3-03-89    9:55a
  482.        BATCH        <DIR>      3-03-89   10:01a
  483.                4 File(s)    280576 bytes free
  484.  
  485.        A:\>_
  486.  
  487.        Notice  that we are using up disk space quickly. Earlier  we  had
  488.        283648 bytes free (when we first issued the dir command with only
  489.        COMMAND.COM  on  the disk). No matter how small a  file  is,  Dos
  490.        allocates  1K  (1000) bytes to it. This allocation  is  called  a
  491.        block, and is the smallest amount of room any file may occupy  on
  492.        a  disk. A block is larger on a hard disk (usually  2000  bytes).
  493.        Even  so, taking our initial value of 283648 bytes, and  dividing
  494.        by 1000, we would come up with about 283. This is the most  files
  495.        we  can  get  on a standard floppy disk  formatted  with  the  /S
  496.        option.  If we had not used the /S option, there would have  been
  497.        362000 bytes free when we started, which translates to 362 files.
  498.  
  499.        As can be seen from the above, even if we are using a small media
  500.        like a floppy disk, we can have several hundred files on a  disk.
  501.        That  is, we could if Dos let us. As I earlier, Dos permits  only
  502.        about  100  files  per  directory.  The clue  here  is  the  word
  503.        directory,  and that's how we get past the 100 file  barrier.  By
  504.        making a directory, we add the capability of adding an additional
  505.        100  files.  Only thing is, we lost one, that is,  the  directory
  506.        entry itself is counted in the root directory.  But even so,  who
  507.        cares, we added over 100 more entry possibilities, so what do  we
  508.        care if we lose one.
  509.  
  510.        Of course, each entry in the root directory could be a  directory
  511.        entry. What that translates to is 100 x 100 or 10,000 ! So if  we
  512.        created  100 directories, we could put 10,000 files on the  disk.
  513.        Whoops,  in actuality, we can't ! Why ?  Because we will run  out
  514.        of physical room !  If each file uses up 1000 bytes each, and  we
  515.        started out with only 283000, then we have room for only the  283
  516.        files, and that includes the directory entries themselves.  IE...
  517.        when  we  created the Directory BATCH, we used  up  another  1000
  518.        bytes.
  519.  
  520.        The  above  holds true for the standard 360K floppy  disks,  what
  521.        about  the  AT 1.2meg (1,200,000 bytes) disks ? Again  each  file
  522.        uses  1000 bytes, so 1.2 million divided by 1000 is 1200 files  !
  523.        Still not really a whole lot. Now what of hard disks ? Each  file
  524.        takes  up 2000 bytes (a little more waste there). A popular  hard
  525.        disk  is the 20 meg unit, usually like a Segate ST210, which  can
  526.        hold over 20 million bytes. 20 million divided by 2000 is 10,000.
  527.        Still not a lot of files, but we are getting there.
  528.  
  529.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  530.  
  531.           by Scanlon Enterprises                         Page 10
  532.  
  533.  
  534.  
  535.        Many  small  business are using 80 and 120 meg units. A  120  meg
  536.        unit  holds  120 million bytes, so, at 2000 bytes per  file,  the
  537.        drive  could potentially hold 60,000 files ! Many users  are  now
  538.        talking about gigabyte drives, this relates to billions of bytes.
  539.        If  a drive held one giga byte (1 billion bytes), then the  drive
  540.        could hold a half million files !
  541.  
  542.        Of course the above numbers assume that all files would be in the
  543.        range of 1 thru 1000 bytes (floppies) or 1 thru 2000 bytes  (hard
  544.        disks).  This  number can shrink quickly for those  having  files
  545.        that  consume several hundred thousand bytes each or  some  files
  546.        that consume more than a million bytes.
  547.  
  548.        Enough  of  this, lets consider the case where we  have  lots  of
  549.        small files. If each file was less than 1000 bytes, and we had  a
  550.        standard  floppy  system (360k bytes each disk),  then  we  could
  551.        potentially  get  360  files on the disk.   This  is  where  your
  552.        directories come in. Could you imagine wading thru 300 plus files
  553.        each  time you wanted to find something ?  Well,  that's  exactly
  554.        what Dos would have to do if we could only use one directory.
  555.  
  556.        When  you  enter  a command, that isn't  one  of  COMMAND.COM  's
  557.        internal  ones,  then Dos has to find the file  related  to  that
  558.        command.  How does Dos look for this file ?  Dos looks  first  in
  559.        the  current directory, first for a file with the extension  COM,
  560.        then with the extension EXE, and finally with the extension  BAT.
  561.        If  Dos  can't find the file in the current directory,  it  would
  562.        start  looking in other directories, names of which it  found  in
  563.        the PATH statement.
  564.  
  565.        By this time, you might be wondering if all of this is necessary,
  566.        well, it is, and we are leading up to something. Anyway, what  is
  567.        this PATH statement (command).  First, we have to tell you  about
  568.        another internal command called SET.
  569.  
  570.  
  571.        Enter the following on the command line : 'set' then press enter.
  572.  
  573.        You should see the following on you display.
  574.  
  575.        A:\>set
  576.        PATH=
  577.        COMSPEC=A:\COMMAND.COM
  578.        PROMPT=$p$g
  579.  
  580.        A:\>_
  581.  
  582.        The  1st 2 entries are always there. PROMPT=$p$g is a  result  of
  583.        our autoexec batch file and the line containing PROMPT $p$g. This
  584.        information   is  in  a  space,  reserved  by  Dos,  called   the
  585.        environment   space.    Dos  sets  aside  160  bytes   for   this
  586.        information, IE... PATH= is 5 bytes, COMSPEC=A:\COMMAND.COM  uses
  587.        22  bytes,  etc... In fact, in the above entry, we  have  used  a
  588.        total of 42 bytes of the environment space.
  589.  
  590.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  591.  
  592.           by Scanlon Enterprises                         Page 11
  593.  
  594.  
  595.  
  596.        If  you  counted all of the characters above,  you'll  find  that
  597.        there  are  only 38 characters shown. The remaining 4  bytes  are
  598.        used by Dos, 2 bytes to separate the entries (1 byte between each
  599.        one, which is 2), and 2 bytes to mark the end. Don't worry  about
  600.        what byte Dos uses to mark the end, let Dos worry about it.   The
  601.        purpose  in telling you this is let you know how much  space  you
  602.        have and that you shouldn't waste it.
  603.  
  604.        Now,  how can you waste the space ?  Well, the 3 entries  in  the
  605.        environment  space  are  not  all that are  place  there.  As  we
  606.        progress  thru  this tutorial, we will discuss more  entries,  as
  607.        well as using up more space for the ones we have, which brings us
  608.        back to our PATH statement (command).
  609.  
  610.        You  will note, above, that the PATH statement had no  parameters
  611.        after  it (PATH= was on a line all by itself). This  means,  that
  612.        Dos will look no further than the current directory for commands.
  613.        Now,  lets test this out. Enter 'CD BATCH' on the  command  line,
  614.        followed  by pressing the enter key. Your Dos prompt  should  now
  615.        look like the following.
  616.  
  617.        A:\BATCH>_
  618.  
  619.        Enter  the following 'PROMPT' and press enter. You will now  have
  620.        the following prompt.
  621.  
  622.        A>_
  623.  
  624.        We're back to the root directory ? No, we have just told dos  NOT
  625.        to inform us of our location.  Without the other information  how
  626.        would we know where we are ?  Enter 'dir' and press enter.  Well,
  627.        that's one way. The directory command always lets you know  where
  628.        you  are.  Of course that's awfully inconvenient. OK,  let's  get
  629.        back our prompt, enter 'prompt $p$g' and press enter. Here we are
  630.        again with our directory name.
  631.  
  632.        Earlier,  we just entered the name TEST to run the batch file  we
  633.        created  earlier,  called TEST.BAT .  Let's try it  again,  enter
  634.        'TEST' and press enter. You got the following message.
  635.  
  636.        Bad command or file name
  637.  
  638.        Well, that's how Dos lets you know that it couldn't find the file
  639.        TEST.BAT  .  So how do we execute a program (command)  from  this
  640.        directory ?  From this directory, you would have to specify where
  641.        the file was, as in the following 'A:\TEST' and press enter.   By
  642.        prefixing  TEST  with the A:\ , we have told Dos to look  in  the
  643.        root directory to find the file TEST.BAT .  Go ahead and try it.
  644.  
  645.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  646.  
  647.           by Scanlon Enterprises                         Page 12
  648.  
  649.  
  650.  
  651.        That's  where the PATH command comes in. We can have  Dos  search
  652.        more  than the current directory for a file by entering a  search
  653.        path  in  the PATH statement. Enter 'PATH=A:\' and  press  enter.
  654.        Now enter 'set' and press enter.  Look at that, the 1st line  now
  655.        has the sequence 'PATH=A:\'.  Now we try out our added path.  You
  656.        should  still  be  in the BATCH directory, and  have  the  prompt
  657.        A:\BATCH . Enter 'test' on the command line and press enter.  The
  658.        batch  file TEST should have executed, clearing your  screen  and
  659.        moving the cursor to the top of the display.
  660.  
  661.        As  can  be  seen,  by  setting the  PATH  to  include  the  root
  662.        directory,  we  can  run a file that exists  in  other  than  the
  663.        current directory.  This will hold true no matter which directory
  664.        you  had  placed your file(s). Let's try another  example.  Enter
  665.        'cd  ..'  (yes, two dots after the cd) and press enter.  You  are
  666.        back at the root directory as depicted by you prompt of  'A:\>_'.
  667.        We  found  a  way to go back one directory level,  and  only  one
  668.        level.    IE...  if  you  were  in  a  directory  2  levels   up,
  669.        (A:\BATCH\GAME  for instance), and entered the previous  command,
  670.        you would be brought back one level (to A:\BATCH).
  671.  
  672.        If  you had been 2 levels up (A:\BATCH\GAME), and entered 'CD  \'
  673.        instead of 'CD ..' you would have been taken all the way back  to
  674.        the root directory.  Remember, if you want to go all the way back
  675.        to the root directory, just enter 'CD \'.
  676.  
  677.        Onward !  Enter 'dir' and press enter.  You should see all of the
  678.        following files listed.
  679.  
  680.        COMMAND.COM
  681.        AUTOEXEC.BAT
  682.        TEST.BAT
  683.  
  684.        Remember, that when you use the DIR function, that the list  does
  685.        not   include  the  decimal  point  in  the  file  names,   IE...
  686.        COMMAND.COM would be COMMAND  COM .  Enter 'COPY *.BAT BATCH' and
  687.        press enter.  We've just used another command, the COPY  command.
  688.        Again, it's an internal command.  How do we know this ?  Because,
  689.        we  don't have a file on this disk called COPY, nor does  a  file
  690.        called  copy  exist in the directory BATCH.  If  everything  went
  691.        correctly  ,  your  display should have a line,  just  above  the
  692.        current command line, which says '2 File(s) copied' .  Enter  the
  693.        command 'cd batch' on the current command line, then press enter.
  694.  
  695.        Again,  we  are in the directory called BATCH, and we  know  this
  696.        because the prompt is 'A:\BATCH>_' .  Now enter 'path=' and press
  697.        enter.   We  have just erased our path, verify this  by  entering
  698.        'set' and pressing enter.  The list should include a line 'PATH='
  699.        with  nothing after the equal sign. This means, that  our  search
  700.        for  a  file  will only occur in the  current  directory.   Enter
  701.        'TEST'  on the current command line and press enter.  The  screen
  702.        will  clear,  and the prompt will be displayed on the  1st  line.
  703.        Enter 'cd \' and press enter.  We are back at the root directory.
  704.  
  705.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  706.  
  707.           by Scanlon Enterprises                         Page 13
  708.  
  709.  
  710.  
  711.        Now, we have 2 copies of the files AUTOEXEC.BAT and TEST.BAT, one
  712.        in the current directory (root), and one in the directory BATCH .
  713.        Let's erase one of these files.  Enter 'ERASE TEST.BAT' and press
  714.        enter.   Enter 'dir' and press enter.  You will see that  we  now
  715.        only have the entries :
  716.  
  717.        COMMAND  COM
  718.        AUTOEXEC BAT
  719.        BATCH         <DIR>
  720.  
  721.        Now, let's discuss what we've done.  We've used the COPY  command
  722.        to  duplicate the files AUTOEXEC.BAT and TEST.BAT and place  them
  723.        into the directory BATCH. We've now used the COPY command several
  724.        times (the first being when we created the AUTOEXEC batch  file),
  725.        so we should give you some information as to what it is doing.
  726.  
  727.        The  copy command is used to copy files.  Your command  line  for
  728.        copy includes the command COPY, the source file, and finally  the
  729.        destination  file.   In our first use, the source  file  was  the
  730.        keyboard (our typing on the keyboard was the data), in the second
  731.        case,  the source files were the files AUTOEXEC.BAT and  TEST.BAT
  732.        on  drive  A,  and  in the current  directory  (the  root).   The
  733.        destination  in our first use was AUTOEXEC.BAT on drive A in  the
  734.        current  directory  (the root), while the second use  placed  the
  735.        destination in the directory BATCH.
  736.  
  737.        Our  second use also excluded entering the actual file  names  in
  738.        the  destination and not fully specifying the source files.   For
  739.        further information on usage of the COPY command, we refer you to
  740.        the Dos user manual.  Since the purpose here is to direct you  in
  741.        the  use  of  batch files, and NOT the actual  use  of  commands,
  742.        except  where  that explanation will enhance the  explanation  of
  743.        that  use  in  the batch file, we suggest, that  if  you  haven't
  744.        already  done so, that you read you Dos manual, and take  special
  745.        note of the commands mentioned on page 4.
  746.  
  747.        Our  new command is ERASE.  You might note, that from now on,  we
  748.        will  be  using the short version of this  command  'DEL'.   Both
  749.        forms  of the command do exactly the same thing.  Dos  has  short
  750.        versions of many of the internal commands, such as 'MD' for MKDIR
  751.        and 'CD' for CHDIR.  The command CD changes the current directory
  752.        to the one specified, as we did when we entered 'CD \', while  MD
  753.        creates  a directory as we did quite a bit back, when we  entered
  754.        MD BATCH on page 8.
  755.  
  756.        Now  lets  again demonstrate the use of PATH.  Enter  'test'  and
  757.        press enter.  You will get the message 'Bad command or file name'
  758.        message. Why ?  Because it's no longer in our current  directory.
  759.        Enter 'dir' and press enter.  See, no TEST.BAT .  Now we can  set
  760.        the path so that Dos can find TEST.  Enter 'path=batch' and press
  761.        enter.   Enter 'set' and press enter.  One of the  lines  display
  762.        should now read 'PATH=batch'.
  763.  
  764.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  765.  
  766.           by Scanlon Enterprises                         Page 14
  767.  
  768.  
  769.  
  770.        We  are  ready to test our search capability.  Enter  'test'  and
  771.        press enter.  The screen cleared and the prompt is at the top  of
  772.        the  display.  The foregoing was a very small example of  how  to
  773.        use path, and we will be giving more uses as we progress thru our
  774.        creation of the AUTOEXEC.BAT file.
  775.  
  776.        What  else  do  we want to do when we first boot  our  machine  ?
  777.        Well,  let's see what we can do so far.  We clear the screen  (to
  778.        make  sure  we  don't have a bunch of junk on  it.   AUTOEXEC  is
  779.        started  with the first line  ECHO OFF, then clears  the  display
  780.        with  CLS, and finally we set the prompt we want to use with  the
  781.        prompt command, PROMPT $P$G .  Lets rewrite the TEST.BAT file  to
  782.        include the path command. Enter the following lines.
  783.  
  784.  
  785.        A:\>COPY CON TEST.BAT
  786.        ECHO OFF
  787.        CLS
  788.        PROMPT $P$G
  789.        PATH=BATCH
  790.        ^Z
  791.  
  792.        Dos responds with '1 file(s) copied'.  And don't forget, that the
  793.        '^Z' in the above is when you hold the control key down and press
  794.        the 'z' key.  Also, you must have pressed enter after each line.
  795.  
  796.        Ok,  let's  test it, enter 'test' on the command line  and  press
  797.        enter.   The screen clears, and a prompt is placed at the top  of
  798.        the  display.  We now have a batch file that when executed,  will
  799.        turn the echo mode off, clear the display, position the cursor at
  800.        the  top of the screen, set our prompt to show the current  drive
  801.        and  path,  and  finally  set the  search  path  to  include  the
  802.        directory BATCH .  What else can we do ?  Before we continue with
  803.        more uses of the batch file, we must back track for a second.
  804.  
  805.        Previously, we showed the Dos environment by entering the command
  806.        'set' at the Dos prompt.  Do it now.  Note the line that contains
  807.        'COMSPEC=A:\COMMAND.COM' .  This line lets Dos know where to find
  808.        the  program 'COMMAND.COM '.  When ever an application  executes,
  809.        and finally concludes, you are returned to the Dos prompt.   What
  810.        is  the Dos prompt ?  The Dos prompt is really a program that  is
  811.        executing,  getting and interpreting your keyboard entries,  thus
  812.        performing  selected  tasks.   The program  doing  this  feat  is
  813.        COMMAND.COM  .   Thus,  when another program is  thru,  Dos  must
  814.        reload  and  start COMMAND.COM again.  To do this, it  must  know
  815.        where  to find it, thus the string COMSPEC=A:\COMMAND.COM in  the
  816.        Dos   environment.   If  this  string  contained   for   instance
  817.        'COMSPEC=A:\BATCH\COMMAND.COM',  then  Dos  would  try  to   find
  818.        COMMAND.COM in the directory BATCH .
  819.  
  820.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  821.  
  822.           by Scanlon Enterprises                         Page 15
  823.  
  824.  
  825.  
  826.        If after executing a program, Dos found a different disk in drive
  827.        A,  and  that  disk  did not  contain  COMMAND.COM  in  the  root
  828.        directory, then the system would halt, you would get a prompt  to
  829.        place a disk containing COMMAND.COM in drive A and press any  key
  830.        to continue.  Dos would not let you enter any new commands  until
  831.        it had reloaded COMMAND.COM.  So why are we telling you this ?
  832.  
  833.        Now  we  can give you the next line for your  AUTOEXEC.BAT  file,
  834.        currently   called   TEST.BAT  .   We  could   enter   a   string
  835.        'COMSPEC=B:\COMMAND.COM  ' or 'COMSPEC=A:\BATCH\COMMAND.COM '  in
  836.        our  batch  file,  so  that  when  executed,  the  new  path  for
  837.        COMMAND.COM  would be set to B:\ (the root directory of drive  B)
  838.        or to A:\BATCH (the directory BATCH on drive A).
  839.  
  840.        Our    next    line   in   the   batch    file    then    becomes
  841.        'COMSPEC=A:\COMMAND.COM  '  .   Now we have  the  five  lines  as
  842.        follows :
  843.  
  844.        ECHO OFF
  845.        CLS
  846.        PROMPT $P$G
  847.        PATH=BATCH
  848.        COMSPEC=A:\COMMAND.COM
  849.  
  850.        Go ahead and use the COPY command to change the file TEST.BAT  to
  851.        the above lines.
  852.  
  853.        One of the biggest problems with batch files, is that they  can't
  854.        key keyboard responses, other than the one used when the  command
  855.        PAUSE is encountered.  When PAUSE is encountered in a batch file,
  856.        the execution of the batch file halts until the user presses  any
  857.        key.  Alternately, the user can press ^C (control C) to halt  the
  858.        batch file completely.  How can we use PAUSE ?
  859.  
  860.        During  execution of the AUTOEXEC batch file, we might include  a
  861.        line such as the following.
  862.  
  863.        ECHO  If you do not want enter the wordprocessor mode,  press  ^C
  864.        now, else
  865.  
  866.        Note, that the line would only be echoed on a single line (we can
  867.        have  80 characters per line), and that else is NOT  followed  by
  868.        any  other  character or punctuation.  This is because  the  line
  869.        following the ECHO command will be the PAUSE command.
  870.  
  871.        Execution  of the PAUSE command produces a message, on  the  line
  872.        following the message in the ECHO command, which is 'Strike a key
  873.        when ready . . .' . Dos would then wait for the user to press any
  874.        key  to continue execution of the batch file, or would  exit  the
  875.        batch file if the user entered ^C.
  876.  
  877.        Once the user entered ^C, Dos would display the following prompt:
  878.  
  879.        Terminate batch job (Y/N)?_
  880.  
  881.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  882.  
  883.           by Scanlon Enterprises                         Page 16
  884.  
  885.  
  886.  
  887.        Dos  would  then  wait  for the user to enter a  'y'  or  'n'  in
  888.        response. The response must be Y or N, or the prompt is reissued.
  889.        If  the user enters Y, then the batch file execution  is  halted,
  890.        and  the  user is given the Dos prompt. However should  the  user
  891.        enter  N, Dos would continue the batch file process  starting  on
  892.        the  line  following the PAUSE command.  The batch  file  process
  893.        also  continues  on the line following the PAUSE command  if  the
  894.        user had pressed any key other than ^C .
  895.  
  896.        What  comes  after the PAUSE command ?  In our  example,  we  can
  897.        enter the following lines.
  898.  
  899.        CD EDITOR
  900.        EDLIN
  901.  
  902.        Our batch file now contains the following lines
  903.  
  904.        ECHO OFF
  905.        CLS
  906.        PROMPT $P$G
  907.        PATH=BATCH
  908.        ECHO  If you do not want enter the wordprocessor mode,  press  ^C
  909.        now, else
  910.        CD EDITOR
  911.        EDLIN
  912.  
  913.        Of course, we don't have a directory called EDITOR, yet. Go ahead
  914.        and change your TEST.BAT file to the above.
  915.  
  916.        Now  that  we  are  actually doing something  that  will  not  be
  917.        transparent.   Please  notice the last line in  our  batch  file,
  918.        which  just has the word EDLIN . This is one of the  files  which
  919.        comes  with  Dos.   The full name, including  the  extension,  is
  920.        EDLIN.COM  . You are probably already ahead of me here, and  have
  921.        the  disk  with EDLIN on it in hand, if not, find it  now.   This
  922.        will be on one of you Dos disks.
  923.  
  924.        We assume you have the disk with EDLIN on it ready.  First  thing
  925.        we have to do, is create the directory EDITOR on our disk.   From
  926.        now  on,  we will call the disk we made, the work disk.   If  you
  927.        aren't already at the root directory on drive A, get there now.
  928.  
  929.        You are now on drive A and in the root directory.  On the command
  930.        line, enter 'MD EDITOR' and press enter. As stated earlier,  this
  931.        creates the directory EDITOR . Now, change directories using  the
  932.        following : cd editor
  933.  
  934.        You should now have a Dos prompt like this :
  935.  
  936.        A:\EDITOR>_
  937.  
  938.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  939.  
  940.           by Scanlon Enterprises                         Page 17
  941.  
  942.  
  943.  
  944.        For those of you with 2 drives, perform the following steps.
  945.  
  946.        Place your disk with EDLIN on it into drive B (close the door).
  947.  
  948.        On the command line enter 'COPY B:EDLIN.COM ' and press enter.
  949.  
  950.        Dos  will copy the file EDLIN.COM from drive B onto drive  A  and
  951.        respond with '1 file(s) copied ' . You now have EDLIN on our work
  952.        disk. Remove the disk in drive B and restore it.
  953.  
  954.        For those of you with only 1 drive, perform the following steps.
  955.        (Those with 2 drives should bypass the follow)
  956.  
  957.        On the command line enter 'COPY B:EDLIN.COM ' and press enter.
  958.        (Yes, we know that you don't have an actual drive B, Dos will use
  959.        drive A for both A and B .)
  960.  
  961.        Dos will respond with the message :
  962.  
  963.        Insert diskette for drive B: and strike
  964.        any key when ready
  965.  
  966.        Remove  our work disk, and insert the Dos disk with EDLIN on  it,
  967.        and  press  enter (any key will work), and  Dos  will  eventually
  968.        respond with :
  969.  
  970.        Insert diskette for drive A: and strike
  971.        any key when ready
  972.  
  973.        Remove  the Dos disk and insert our work disk, then press  enter.
  974.        Dos will respond with :
  975.  
  976.             1 File(s) copied
  977.  
  978.        You now have EDLIN on your work disk (regardless of which  method
  979.        you  used).  Perhaps  you've  been wondering  why  we  have  been
  980.        creating  TEST.BAT each time we want to add something to  it.  It
  981.        has  been  our  experience that some users are  unaware  of  this
  982.        particular use, and we wanted you to have the experience of using
  983.        this  method.   Using  the  'COPY  CON  filename  '  approach  is
  984.        especially  good  for creating small batch files,  however,  once
  985.        created, it can be a drag constantly changing an existing one  as
  986.        we are doing.
  987.  
  988.        From now on, it will be up to you, the user to edit or change the
  989.        batch file TEST, in whatever fashion you prefer.  We will not, in
  990.        this  document, teach you how to use EDLIN, if you want to  learn
  991.        how  to use it, we suggest that you pull out your Dos manual  and
  992.        start  experimenting  with  EDLIN before you  precede  with  this
  993.        document, as we will be directing you, continually to change  the
  994.        file TEST, and we will be creating new batch files as well.
  995.  
  996.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  997.  
  998.           by Scanlon Enterprises                         Page 18
  999.  
  1000.  
  1001.  
  1002.        For the time being, we will cease our explanation of the AUTOEXEC
  1003.        batch  file  and begin the process of learning other  useful  Dos
  1004.        commands to be used with batch files in general.
  1005.  
  1006.        Earlier,  we  used the DIR command from the Dos  prompt  (command
  1007.        line),  now we are going to add to your knowledge of its use.  At
  1008.        your  current Dos prompt enter 'dir' and press enter. You  should
  1009.        have a list similar to the following :
  1010.  
  1011.         Volume in drive A has no label
  1012.         Directory of  A:\
  1013.  
  1014.        COMMAND  COM    25276   3-03-1980   9:38a
  1015.        AUTOEXEC BAT       13   3-03-1987   8:00a
  1016.        TEST     BAT       28   3-03-1987   8:15a
  1017.        BATCH        <DIR>      3-03-1987   8:30a
  1018.        EDITOR       <DIR>      3-03-1987   8:45a
  1019.               5 File(s)     271360 bytes free
  1020.  
  1021.        A  file entry consists of first, up to 8 characters for the  file
  1022.        name,  a  space and 3 characters for the extension,  a  few  more
  1023.        spaces,  then the file size (how many bytes it has), a  few  more
  1024.        spaces,  then the date the file was created (this may not be  the
  1025.        date   you  placed  it  on  your  disk,  as  is  the  case   with
  1026.        COMMAND.COM),  then  a few more spaces separate  the  last  entry
  1027.        which  is the time of day the file was created (again,  this  may
  1028.        not  be  the  time  of day you copied it  to  the  disk  as  with
  1029.        COMMAND.COM).  As observed in the above list, COMMAND.COM  has  a
  1030.        creation date (yours may differ) of 3-03-1980 and a time of 9:38a
  1031.        which was the time that file was created (perhaps by  Microsoft).
  1032.        The date we copied the file to our disk, using FORMAT with the /S
  1033.        option, does NOT apply. IE.... if you have a file called  XYZ.COM
  1034.        with  a creation date of 3-05-1982 and copy it to  another  disk,
  1035.        that  file on the new disk will have the same date.  However,  if
  1036.        you modify file XYZ.COM on the new disk, and resave it, then that
  1037.        file  will  get  a  new date, equal to  the  date  you  made  the
  1038.        modification.
  1039.  
  1040.        Now,  look  at the directory list again, and notice  the  last  2
  1041.        entries.  These are directory entries.  A directory entry  has  a
  1042.        name (and may also have an extension), then will have an entry of
  1043.        <DIR>  in  the  size field (directory names  don't  have  a  byte
  1044.        count),  and  the  last 2 fields are the same as  that  used  for
  1045.        files, IE... the creation date and time.
  1046.  
  1047.        The  directory  command can be append with one  of  two  switches
  1048.        (they  can  not be used at the same time). The first  one  is  to
  1049.        append  the switch for pause. This is often called page. The  use
  1050.        of this command is 'dir /p '. What does this form do ?  Well,  if
  1051.        we  had more files on our disk (about 22) the screen would  pause
  1052.        it's  scroll when it got full.  Since we don't have enough  files
  1053.        to demonstrate it, we'll go on to the next switch /w.
  1054.  
  1055.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1056.  
  1057.           by Scanlon Enterprises                         Page 19
  1058.  
  1059.  
  1060.  
  1061.        The  /w  switch, when appended after the dir command  causes  the
  1062.        directory  list  to  use  5  columns,  and  drop  off  the  extra
  1063.        information  (file size and time and date of creation).  Try  the
  1064.        following  at your Dos prompt. Enter 'dir /w ' then press  enter.
  1065.        Your should have a display similar to the following :
  1066.  
  1067.         Volume in drive A has no label
  1068.         Directory of  A:\
  1069.  
  1070.        COMMAND  COM    AUTOEXEC BAT    TEST     BAT    BATCH     EDITOR
  1071.                5 File(s)    271360 bytes free
  1072.  
  1073.  
  1074.        All of the files are listed starting from the left, with 5  files
  1075.        per line. If we had more files, there would be 2 lines or more.
  1076.  
  1077.        Another  popular  use of the AUTOEXEC batch file is to  have  the
  1078.        batch  file  display a directory listing as the last line  to  be
  1079.        executed in the batch file.
  1080.  
  1081.        EXAMPLE:
  1082.  
  1083.        ECHO OFF
  1084.        CLS
  1085.        PROMPT $P$G
  1086.        PATH=BATCH
  1087.        DIR /W
  1088.  
  1089.        Upon  booting a system with this as an AUTOEXEC batch  file,  the
  1090.        screen would clear, and a directory list (similar to that  above)
  1091.        would be displayed, and the Dos prompt would follow.
  1092.  
  1093.        There  is  another batch file command which can be  important  in
  1094.        your  AUTOEXEC  batch file, and that is the  BREAK  command.  The
  1095.        break  command  is followed by one of the words ON or  OFF.   For
  1096.        instance, the command BREAK ON sets the system to respond to  the
  1097.        ^C  sequence  more often than the command BREAK OFF .   For  more
  1098.        details,  we refer you to your Dos manual. Our suggestion  is  to
  1099.        include the command BREAK ON in your AUTOEXEC batch file, and  if
  1100.        you  need  to turn ^C testing off, you can always  put  the  line
  1101.        BREAK OFF into another batch file.
  1102.  
  1103.        Another  very  popular  use  of the AUTOEXEC  batch  file  is  to
  1104.        autostart  an application (or game) when the disk is  booted.  An
  1105.        example of this would be :
  1106.  
  1107.        ECHO OFF
  1108.        CLS
  1109.        PINBALL
  1110.        AUTOEXEC
  1111.  
  1112.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1113.  
  1114.           by Scanlon Enterprises                         Page 20
  1115.  
  1116.  
  1117.  
  1118.        The above batch file would continually run the program PINBALL  .
  1119.        The  only way out of the loop would be to press ^C at  the  right
  1120.        moment  of time to halt the batch file. The last line, calls  the
  1121.        AUTOEXEC batch file again.  A similar approach would be to use  a
  1122.        label, as in :
  1123.  
  1124.        ECHO OFF
  1125.        :START
  1126.        CLS
  1127.        PINBALL
  1128.        GOTO START
  1129.  
  1130.        Again, we have a batch file that will continually execute itself,
  1131.        but  this time, the loop is internal. When Dos gets to  the  last
  1132.        line, it jumps back to the line with :START on it, and loops back
  1133.        thru. This type of AUTOEXEC is great for disks that have only one
  1134.        program on it, however, if you had one with several programs, and
  1135.        you wanted to execute a particular one first, then the  following
  1136.        would be the batch file to use :
  1137.  
  1138.        ECHO OFF
  1139.        CLS
  1140.        PROMPT $P$G
  1141.        PATH BATCH
  1142.        MENU
  1143.  
  1144.        The  last line contains the name of the program you want  to  run
  1145.        first.  In this case, it's a menu. This menu could be one of many
  1146.        that are available in the Public Domain, or it could be our GMENU
  1147.        program.   A menu (like our GMENU) will display a list  of  other
  1148.        programs, wait for you to select one, then execute that  program,
  1149.        when done with the selected program, you will be returned back to
  1150.        the menu (as with our GMENU) or maybe back to Dos.
  1151.  
  1152.        Here's another good example of using the AUTOEXEC batch file.
  1153.  
  1154.        ECHO OFF
  1155.        CLS
  1156.        PATH BATCH
  1157.        ECHO Have you backed up lately ?
  1158.        PROMPT The current date is $d$_
  1159.        PROMPT The current time is : $t$_
  1160.        PROMPT $P$G
  1161.        DIR /W
  1162.  
  1163.        This  little number will first display the line 'Have you  backed
  1164.        up  lately ? ' then the line 'The current date is 3-03-87  '  and
  1165.        finally  the  line  'The current time is 8:45 ',  followed  by  a
  1166.        directory  list  and the Dos prompt. Notice that  the  first  two
  1167.        lines  that  begin  with PROMPT end with a  dollar  sign  and  an
  1168.        underline.  This sequence forces the prompt to issue  a  carriage
  1169.        return.  Without this sequence, the first two lines would  be  on
  1170.        the same line.
  1171.  
  1172.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1173.  
  1174.           by Scanlon Enterprises                         Page 21
  1175.  
  1176.  
  1177.  
  1178.        Why  did  we  put the messages 'The current date is  '  and  'The
  1179.        current  time is ' into the prompt string ?  If we had used  ECHO
  1180.        to  display the strings, then the strings would be on  one  line,
  1181.        while  the time or date would be on another. In other words,  the
  1182.        ECHO command always issues a carriage return.
  1183.  
  1184.        For  those  without  real  time  clocks  in  their  systems,  the
  1185.        following AUTOEXEC batch files has proven useful.
  1186.  
  1187.        ECHO OFF
  1188.        CLS
  1189.        PATH=BATCH
  1190.        TIME
  1191.        DATE
  1192.        PROMPT $P$G
  1193.        ECHO Have you backed up lately ?
  1194.        DIR /W
  1195.  
  1196.        In  this example, we get Dos to prompt the user for the time  and
  1197.        date.  In both this example and the previous example, we have the
  1198.        line  'ECHO Have you backed up lately ? '.  We suggest  that  you
  1199.        keep back up copies of all your original disks, and also  backups
  1200.        of all work disks.  This is so that in case any thing happened to
  1201.        the  current disk, you will always have a back up (or spare).  It
  1202.        will only take one time of loosing a disk to make you a believer!
  1203.  
  1204.        Let's try a new command ! Actually we are going to test a  couple
  1205.        of  new commands. Create a new TEST.BAT file with  the  following
  1206.        lines.
  1207.  
  1208.        ECHO OFF
  1209.        CLS
  1210.        IF EXIST HELP\HELP.COM GOTO GHELP
  1211.        ECHO Help is NOT available
  1212.        GOTO EXIT
  1213.        :GHELP
  1214.        ECHO Help IS available
  1215.        :EXIT
  1216.  
  1217.        Execute  the  file  by entering 'test' at the  Dos  prompt.  Your
  1218.        screen  will clear, the message 'Help is NOT available ' will  be
  1219.        displayed, and you will be given the Dos prompt.
  1220.  
  1221.        Now  lets create a directory called HELP. Enter the  command  'md
  1222.        help'.  Now  enter into the newly created directory  by  entering
  1223.        the  command  'cd  help'. You should now have  a  dos  prompt  of
  1224.        'A:\HELP>_'  . Now we need to create the file HELP.COM . Do  that
  1225.        by  entering the command 'COPY ..\COMMAND.COM HELP.COM  '  (don't
  1226.        forget  to  press enter after each of these commands).  Dos  will
  1227.        respond with '1 File(s) copied' and give you  another prompt.  We
  1228.        are now ready to try out the batch file again.
  1229.  
  1230.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1231.  
  1232.           by Scanlon Enterprises                         Page 22
  1233.  
  1234.  
  1235.  
  1236.        Enter  'cd  \'  at the Dos prompt, you will now be  in  the  root
  1237.        directory.  Enter the following from the Dos prompt,  'test'  and
  1238.        press  enter.  If  we've done every thing  right,  the  following
  1239.        message will be displayed after the display is cleared.
  1240.  
  1241.        Help IS available
  1242.  
  1243.        followed  by the Dos prompt.  Of course, we don't really  have  a
  1244.        HELP  program,  all we have is a renamed COMMAND.COM  file.  Now,
  1245.        let's  clear this directory and try something else.  Perform  the
  1246.        following steps.
  1247.  
  1248.        Enter 'cd help' and press enter
  1249.        Enter 'del help.com' and press enter
  1250.        Enter 'cd \' and press enter
  1251.        Enter 'rd help' and press enter
  1252.        Enter 'dir' and press enter
  1253.  
  1254.        The  directory listing should be like that on page 18,  and  your
  1255.        prompt should be 'A:\>_ '.
  1256.  
  1257.        Look  at the lines for the TEST.BAT file on page 21.  Notice  the
  1258.        3rd line, this is where all the new stuff is happening. The first
  1259.        time  we  ran  the batch file, the directory HELP  had  not  been
  1260.        created, nor had the file HELP.COM . That 3rd line tests for  the
  1261.        existence (IF EXIST) of HELP.COM in the directory HELP, and if it
  1262.        does  NOT  exist, will execute the line  immediately  after  that
  1263.        line,  which says 'Help is NOT available', then branches  to  the
  1264.        line  :EXIT . If the file HELP.COM does exist in  directory  HELP
  1265.        then  the  program branches to the line :GHELP and  displays  the
  1266.        message  'Help IS available. Now we've used GOTO, IF  and  EXIST.
  1267.        These 3 commands are often used together.
  1268.  
  1269.        By  now,  you may have guessed, that in actuality,  that  writing
  1270.        batch files is a form of programming !  One of the big advantages
  1271.        of writing programs using a batch file, is that the language  can
  1272.        grow to meet your needs.
  1273.  
  1274.        Perhaps you've guessed why we have used the IF EXIST feature. Our
  1275.        test for the existence of HELP.COM is a common occurrence of many
  1276.        batch  files  written by professional programmers. IE...  if  the
  1277.        file  did not exist, we might have exited the batch file  with  a
  1278.        warning  message,  asking  the user to make sure  that  the  file
  1279.        HELP.COM  is  copied on to the disk, or we might have  looked  on
  1280.        another  drive,  or we might have waited for the user  to  insert
  1281.        another  disk.   On the other hand if the file  had  been  found,
  1282.        perhaps we would have continued on an executed the program HELP .
  1283.  
  1284.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1285.  
  1286.           by Scanlon Enterprises                         Page 23
  1287.  
  1288.  
  1289.  
  1290.        Another  very  powerful feature of using batch files,  and  which
  1291.        seems  seldom to be used, is the FOR %F IN()DO  command  sequence
  1292.        These  commands are used together. Lets take a look at what be  a
  1293.        typical use of this powerful command (typical is used for lack of
  1294.        a  better  definition). If a batch file contained  the  following
  1295.        line:
  1296.  
  1297.        FOR %%F IN (%1, %2, %3, %4) DO DEL %%F
  1298.  
  1299.        We  could  delete  4 unique files at one time,  by  entering  one
  1300.        command with all of the files named on it.  Let's call this  file
  1301.        D.BAT  .  A command we might give would be D  COMMAND.COM  FILE.1
  1302.        TEST.BAT  TEST.DAT . Executing the command, we would see  on  the
  1303.        display the following sequences of commands.
  1304.  
  1305.  
  1306.        A:\>FOR %F IN (COMMAND.COM FILE.1 TEST.BAT TEST.DAT) DO DEL %F
  1307.  
  1308.        A:\>DEL COMMAND.COM
  1309.  
  1310.        A:\>DEL FILE.1
  1311.  
  1312.        A:\>DEL TEST.BAT
  1313.  
  1314.        A:\>DEL TEST.DAT
  1315.  
  1316.        Of course we could have made the procedure invisible by  entering
  1317.        the following commands in the file, instead of the one line.
  1318.  
  1319.        ECHO OFF
  1320.        CLS
  1321.        FOR %%F IN (%1, %2, %3, %4) DO DEL %%F
  1322.  
  1323.        There  it  is, a real honest to God program that  does  something
  1324.        useful.  So how do we use this ?  As we mentioned  much  earlier,
  1325.        the  path command points to alternate drives and directories  for
  1326.        Dos  to  search for a given command. Also, we have, on  our  work
  1327.        disk,  set the PATH to include the directory BATCH on drive  A  .
  1328.        What you would do, is place this new batch file in the  directory
  1329.        A:\BATCH and then no matter which directory you might be in,  you
  1330.        could enter 'D ' and a string of files you want to delete.
  1331.  
  1332.        Let's improve on a powerful utility. Yes, this can definitely  be
  1333.        called  a utility. You may ask how can this be improved ?   Well,
  1334.        I'll borrow an age old adage, 'Anything can be improved.'.
  1335.  
  1336.        The  improvement  calls for adding to our set  of  commands.  Dos
  1337.        gives us another powerful (and again, not often used) batch  file
  1338.        command.  What is it ?  Why SHIFT, of course ! Lets  rewrite  our
  1339.        batch file, including the SHIFT command.
  1340.  
  1341.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1342.  
  1343.           by Scanlon Enterprises                         Page 24
  1344.  
  1345.  
  1346.  
  1347.        ECHO OFF
  1348.        CLS
  1349.        :DODEL
  1350.        IF '%1'=='' GOTO EXIT
  1351.        DEL %1
  1352.        SHIFT
  1353.        GOTO DODEL
  1354.        :EXIT
  1355.  
  1356.        Quit  a bit different ! How does it work ?  We'll skip all  lines
  1357.        that we've already discussed, so starting on line 3, we find  the
  1358.        label ':DODEL ', all labels are prefixed by a colon, and are  the
  1359.        only  entries on the line. The next line tests for the  condition
  1360.        when the variable %1 is empty. If the variable is empty, we exit.
  1361.        Now  we  simply have a command to del the variable %1  (line  5).
  1362.        Line  6 is probably the key to this whole batch file. The  single
  1363.        expression  SHIFT.  What this does is cause Dos to point  to  the
  1364.        next  entered expression from the entered command line. The  next
  1365.        line  simply loops thru to label ':DODEL '. We get to  the  label
  1366.        ':EXIT 'from the 4th line, when %1 is empty.
  1367.  
  1368.        OK, you've got a question. What is a variable, and what the  heck
  1369.        is  %1 ?  Dos allows us 10 variables plus the variable %%F as  we
  1370.        used in the previous example. The variables we are allowed to use
  1371.        are  %0 thru %9. We can't use %0, because Dos has  reserved  that
  1372.        for a particular use (we will go  into that later), which  leaves
  1373.        us  9 variables. Well, what's a variable ? A variable is  any  of
  1374.        several  passed parameters on a command line when you  execute  a
  1375.        program  directly  from  the Dos prompt.  IE...  in  our  earlier
  1376.        example we entered 'D COMMAND.COM FILE.1 TEST.BAT TEST.DAT ' each
  1377.        entry after the 'D ' is a variable, and Dos assigns them  numbers
  1378.        starting with 1 ! Thus, COMMAND.COM becomes %1, FILE.1 becomes %2
  1379.        and etc.....
  1380.  
  1381.        This  is  where SHIFT comes in. When Shift  is  encountered,  all
  1382.        variables are shifted down one number, thus, COMMAND.COM is lost,
  1383.        FILE.1 becomes %1, TEST.BAT becomes %2, etc....
  1384.  
  1385.        Wow !  Now you see why this is so powerful !  Using this, we  can
  1386.        virtually have an unlimited number of parameters.  This of course
  1387.        isn't true.  Dos allows us a line length of up to 127 characters.
  1388.        What this translates to depends upon the length of each file name
  1389.        entered on the line.  Thus if your command is a single character,
  1390.        as  in 'D', we loose only 2 characters (the required space  after
  1391.        the command), thus giving us 125 bytes for our file list. If each
  1392.        name  averaged  9 bytes (counting extension) then we  would  have
  1393.        room  for  125 / 9 entries or about 13 entries.  The  imagination
  1394.        runs  wild  ! Think of this capability used with  some  of  those
  1395.        other Dos commands !
  1396.  
  1397.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1398.  
  1399.           by Scanlon Enterprises                         Page 25
  1400.  
  1401.  
  1402.  
  1403.        Now  let's discuss the next very powerful command. You will  find
  1404.        many Dos books and computer consultants as well as those who  say
  1405.        they  know,  that you can NOT call another  batch  file,  without
  1406.        loading  in a second copy of COMMAND.COM .  I will now  tell  you
  1407.        that  is totally untrue, and will precede to show YOU how  to  do
  1408.        it.  One of the most under used Dos commands is the SET  command,
  1409.        which can be used even from the command line.  We've already used
  1410.        this to show the Dos environment data, such as PATH and COMSPEC .
  1411.        SET  can be used to create any variable !  The only limit to  the
  1412.        name are the legal characters that Dos itself limits us to.
  1413.  
  1414.        Lets  try one from the Dos prompt, just to show you what  we  can
  1415.        do.  Enter  'SET NAME=Ed' and press enter. Now enter 'set  '  and
  1416.        press enter. You will see the following lines.
  1417.  
  1418.        PATH=BATCH
  1419.        COMSPEC=A:\COMMAND.COM
  1420.        PROMPT=$P$G
  1421.        NAME=Ed
  1422.  
  1423.        How  about that !  What good is it ?  We'll get to that  shortly,
  1424.        but  first  a  word  more about  the  environment  and  the  PATH
  1425.        statement.  At the beginning (somewhere), we mentioned  the  fact
  1426.        that Dos sets aside only 160 bytes of space for the  environment.
  1427.        That  is true, except for the case we change that, at boot  time,
  1428.        from the CONFIG.SYS file.
  1429.  
  1430.        MORE  ROOM FOR VARIABLES : That's the name of the game,  starting
  1431.        with Dos 3.2, we can change the size of the Dos environment  with
  1432.        the  CONFIG command 'SHELL=A:\COMMAND.COM /E:nnn A:\ /P  '.  This
  1433.        line  (usually the last line), will load COMMAND.COM, with  'nnn'
  1434.        bytes  of  environment space, instead of the default  160  bytes.
  1435.        IE...if you entered 1000 for nnn, then you would have 1000  bytes
  1436.        available for the environment variables.
  1437.  
  1438.        Why  do we need more room ?  You may think at first  sight,  that
  1439.        160  bytes is too many, after all, we have only used about 50  or
  1440.        so bytes. OK, lets take another look at the PATH command.
  1441.  
  1442.        If  you are working with a system which only has  floppy  drives,
  1443.        you might want to bypass this section, and start back on page 27.
  1444.  
  1445.        For hard disk systems, especially those larger than 20 megabytes,
  1446.        a   user   should   create   several   directories.     IE...your
  1447.        wordprocessor(s)  should  be in a directory separate  from  let's
  1448.        say,  Dos  utilities  ; Dos utilities should be  in  a  directory
  1449.        separate  from  let's say, a graphics program ; and  yet  another
  1450.        directory should be created for games, and yet another for Basic,
  1451.        and yet another for batch files, etc.....
  1452.  
  1453.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1454.  
  1455.           by Scanlon Enterprises                         Page 26
  1456.  
  1457.  
  1458.  
  1459.        Why do this ? Well, one reason is that we only have 8  characters
  1460.        to  play  with  for  file names, thus  many  programs  come  with
  1461.        duplicate  files,  such as README.DOC (often found  on  Shareware
  1462.        disks),  INSTALL.COM (or EXE) is often a file used to  install  a
  1463.        particular  program, etc... Let's face it, how many  recognizable
  1464.        words  can be generated from words with lengths not to  exceed  8
  1465.        bytes  ?  Back  to the PATH command. We  already  have  one  path
  1466.        defined  as  BATCH,  but for hard disk users,  this  may  not  be
  1467.        enough. IE.. some files you may have to refer to are going to  be
  1468.        DOS commands (the external ones), like FORMAT, DISKCOPY, etc....
  1469.  
  1470.        Usually these commands are placed in a directory labeled DOS,  or
  1471.        MSDOS,  so  we would add that path to our PATH  directive,  which
  1472.        then  becomes  PATH=A:\BATCH;C:\MSDOS  .  Notice  the  semi-colon
  1473.        between  path names, and that we have used the drive letter  C  .
  1474.        The first hard disk in a system is usually C, even if there isn't
  1475.        a  B . Assuming that we have all of the Dos external commands  in
  1476.        the directory MSDOS, what other directory paths might we have  to
  1477.        include ? Well, how about your word processor, you will  probably
  1478.        want  to  have  access to that from else where.  So  we  add  the
  1479.        directory path of C:\EDITORS and come up with the following :
  1480.  
  1481.        PATH=A:\BATCH;C:\MSDOS;C:\EDITORS
  1482.  
  1483.        Just those 3 paths use up about 35 bytes. Many systems have  path
  1484.        statements with as many as 8 or 9 different paths. At an  average
  1485.        of 8 bytes per entry, that would represent 64 bytes to 72  bytes.
  1486.        Then,  some  programs  require  a Dos  variable  be  set  in  the
  1487.        environment, thus, the bytes add up. We suggest a minimum of  500
  1488.        bytes be set aside for the environment space, or preferably  1000
  1489.        if you have the room.
  1490.  
  1491.        Also,  for  your  information,  Dos searches  for  files  in  the
  1492.        following  order.   First  a  search  is  made  of  the   current
  1493.        directory,  then, if the path statement has been set, the  search
  1494.        is  conducted starting at the first entry in the  PATH  variable,
  1495.        then  the  second,  etc...  We suggest that  you  set  your  PATH
  1496.        variable  such that those programs or utilities called  the  most
  1497.        often are in the first entry.
  1498.  
  1499.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1500.  
  1501.           by Scanlon Enterprises                         Page 27
  1502.  
  1503.  
  1504.  
  1505.        We  can now precede to show how one batch file can call  another.
  1506.        For our discussion, we will use two variables, CALLER and RETURN.
  1507.        The first variable will be set by the caller to give the name  of
  1508.        the batch file to return to from the called batch file, while the
  1509.        second one will be where in the batch file to return to.   Here's
  1510.        our example.
  1511.  
  1512.        Batch file 1, CALLER.BAT
  1513.  
  1514.        IF '%RETURN%'=='' GOTO STDENTR
  1515.        GOTO %RETURN%
  1516.        IF ERRORLEVEL 1 GOTO DOERR
  1517.        :STDENTR
  1518.        ECHO OFF
  1519.        CLS
  1520.        SET CALLER=CALLER
  1521.        SET RETURN=WEBACK
  1522.        CALLED
  1523.        :WEBACK
  1524.        ECHO Back from subroutine
  1525.        GOTO EXIT
  1526.        :DOERR
  1527.        ECHO We had an error during execution
  1528.        :EXIT
  1529.  
  1530.        Batch file 2, CALLED.BAT
  1531.  
  1532.        ECHO Subroutine 1
  1533.        IF '%CALLER%'==''GOTO DOERR
  1534.        %CALLER%
  1535.        :DOERR
  1536.        Echo Subroutine exit failure
  1537.        :EXIT
  1538.  
  1539.        Let's  see  what we did. The first batch file  upon  running  the
  1540.        first  time  falls thru to the section starting  with  the  label
  1541.        :STDENTR  ,  setting  the  variables CALLER  and  RETURN  ,  then
  1542.        executing  the subroutine CALLED.  CALLED then displays the  line
  1543.        Subroutine  1, and exits back to the calling batch file  via  the
  1544.        line  %CALLER%  .  When CALLER is again executed,  it  finds  the
  1545.        variables  RETURN  and CALLER set, so will then  start  executing
  1546.        starting  at  the label :WEBACK , which displays the  line  'Back
  1547.        from  subroutine'.   As you can see, using this approach  we  not
  1548.        only can call another batch file and return, but we can return to
  1549.        any  where  we  want, within the batch  file,  provided  we  have
  1550.        defined  a  label.  With memory a premium in some  systems,  this
  1551.        approach  saves quite a bit of memory for running programs,  even
  1552.        while doing so from a batch file.
  1553.  
  1554.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1555.  
  1556.           by Scanlon Enterprises                         Page 28
  1557.  
  1558.  
  1559.  
  1560.        Notice  again, the CALLER batch file.  Here is a line  that  uses
  1561.        the  ERRORLEVEL command (function). If the name specified in  the
  1562.        RETURN  variable is NOT one of the labels in our batch file,  and
  1563.        Dos tries to goto that line, an errorlevel will be generated.  In
  1564.        this  case,  an ERRORLEVEL of 1 means failure. If there  were  no
  1565.        failure, then execution would precede at the specified label held
  1566.        in the variable RETURN.
  1567.  
  1568.        There  are still some internal Dos commands we  haven't  covered,
  1569.        but those will be covered when we start discussing our own  batch
  1570.        file utilities (SEBFU). Now, we will again refer back to the  use
  1571.        of directories. We feel that proper usage of directories will aid
  1572.        the user on hard disk systems, and in many cases, those with only
  1573.        floppy drives.
  1574.  
  1575.        Other  than  the fact that there is a good likely  hood  of  file
  1576.        duplication (file names the same), what other reasons can we give
  1577.        to  use directories.  The best reason, is common sense.  What  do
  1578.        we mean by that ?  Well, if you have one directory with 100 files
  1579.        in it, how will you find a particular one ?  An example, you  are
  1580.        using your word processor, and have created the file TEDDY.LTR  ,
  1581.        so  far  no problem.  Now a week later, you create  another  file
  1582.        called TEDDY.LET . Still no problem. OK, a month later you are in
  1583.        your word processor and need to view and edit your TEDDY  letter.
  1584.        Well, you get a directory list, and there they are, 15 TEDDY's  .
  1585.        Now  what  ? Each TEDDY is different, but you only  remember  the
  1586.        word  TEDDY,  and  you  have  TEDDY.LTR,  TEDDY.LET,  TEDDYH.LTR,
  1587.        TEDDYZ.LET,  TEDDY.LT, etc.... Which is the one you want ?  Well,
  1588.        if you are in Dos with the directory command, you can use the DIR
  1589.        with  the /p (for page) option to scroll thru them and  look  for
  1590.        the correct date, if you remember it.
  1591.  
  1592.        The previous was not a common event, more likely, you just  won't
  1593.        remember  the name you gave the document or letter. That's  where
  1594.        directories  come  in.  We can create directories  for  different
  1595.        types of letters, IE... separate business from personal, create a
  1596.        directory  for  documents,  one  for  resume's,  etc....  Another
  1597.        approach  would  be to have directories named after  the  months,
  1598.        IE... JAN, FEB, MAR etc...
  1599.  
  1600.        What about Dos commands and those nifty utilities (like our batch
  1601.        file  utilities). Where do you put them ?  We mentioned  earlier,
  1602.        that the Dos commands like FORMAT, DISKCOPY, etc... could go in a
  1603.        directory called DOS, but you might not want to put the utilities
  1604.        there, after all, there may be names that are alike, and if there
  1605.        are  too many, how do you keep track of them ? Another thing,  is
  1606.        the  search,  you  don't  want  you  system  tied  up   searching
  1607.        constantly  for  files, so you place those files  that  are  most
  1608.        often  used in one directory, and those less frequently  used  in
  1609.        another.
  1610.  
  1611.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1612.  
  1613.           by Scanlon Enterprises                         Page 29
  1614.  
  1615.  
  1616.  
  1617.        We are including the following only as a recommendation, not as a
  1618.        must do. For those of you who want fast systems and systems where
  1619.        you can find something, we suggest the following directories.
  1620.  
  1621.  
  1622.        In the root directory create a directory called DOS. This will be
  1623.        where you place all of your MS/PC-DOS utilities (like FORMAT).
  1624.  
  1625.        Change directories to DOS, and start making subdirectories of DOS
  1626.        in the following manner.  Make directories starting as LEV1, then
  1627.        LEV2, LEV3, etc... Each level (as in LEV1) specifies where in the
  1628.        PATH chain to place that directory name.  Example :
  1629.  
  1630.        PATH=C:\DOS\LEV1;C:\DOS\LEV2;C:\DOS\LEV3;etc....
  1631.  
  1632.        Make  only as many levels as you will need (probably 3). We  will
  1633.        base  this discussion on 3 levels, as that will suffice for  most
  1634.        users.  Level 1 (LEV1) should contain the following files :
  1635.  
  1636.        DISKCOPY    FC          FIND        FORMAT      MORE        SORT
  1637.        XCOPY       COMP
  1638.  
  1639.        Level 2 should contain these files :
  1640.  
  1641.        ATTRIB      CHKDSK      DISKCOMP    JOIN        LABEL       MODE
  1642.        PRINT       REPLACE     SYS
  1643.  
  1644.        Level 3 should contain the rest of PC/MS-DOS files.
  1645.  
  1646.        APPEND      ASSIGN      BACKUP      EXE2BIN     FASTOPEN    FDISK
  1647.        GRAFTABL    GRAPHICS    JOIN        KEYB        NLSFUNC
  1648.        RECOVER     RESTORE     SELECT      SHARE       SUBST       TREE
  1649.  
  1650.        The above is not written in cast iron, but should only be used as
  1651.        a starting guide. Some of you will be using GRAFTABL and GRAPHICS
  1652.        much  more often, and should place them in lower  levels,  others
  1653.        will be using EXE2BIN more often. All we have attempted to do, is
  1654.        give you some form of a guide.
  1655.  
  1656.        Now you will want to change back to the root directory (cd \) and
  1657.        create  a  directory  called BAT.  This  directory  will  contain
  1658.        commonly  used batch files (generic types), like our  example  of
  1659.        the delete utility from page 24.
  1660.  
  1661.        Your  root directory should contain only 3 files,  COMMAND.COM  ,
  1662.        AUTOEXEC.BAT , and CONFIG.SYS .
  1663.  
  1664.        Now  make  a directory called UTILS. This is where  you  will  be
  1665.        placing  our  Batch File Utilities (SEBFU) and many  more  Public
  1666.        Domain / Shareware utilities (Maybe even the Norton Utilities).
  1667.  
  1668.        Change to the newly created directory (cd utils).
  1669.  
  1670.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1671.  
  1672.           by Scanlon Enterprises                         Page 30
  1673.  
  1674.  
  1675.  
  1676.        We are now going to create directories inside the directory UTILS
  1677.  
  1678.        The  first  one will of course be a directory for  our  utilities
  1679.        (SEBFU). Make a directory called SEBFU1 . This is where you  will
  1680.        place  all  of the Batch file utilities that you  will  use  most
  1681.        often. Examples of often used batch commands are :
  1682.  
  1683.        LOCATE      CLR         SCROLL      BEEP        COFF        COLOR
  1684.        CT          CUON        DBLBOX      DLINE       DSKRDY      GKEY
  1685.        INKEY       LINE        RESPONSE    SHOWVAR     SNGLBOX     SOUND
  1686.        STRING      WAIT        WRITE       WRITEF      YN          GETCR
  1687.  
  1688.  
  1689.        The rest of our utilities will go into a directory called SEBFU2.
  1690.        In  other  words, go back one directory level to  UTILS,  make  a
  1691.        directory called SEBFU2, and copy the rest of our utilities  into
  1692.        the directory. The utilities are :
  1693.  
  1694.        DAYOFMO     DETANSI     ENVSIZE     FF          GDRIVE      GETCC
  1695.        GETMCB      GETVER      GMEM        GMODE       INVERT      LEN
  1696.        LPT1TO2     PRDY        PRINT       PRINTC      PRINTF
  1697.        PRNSET      SCROLMSG    SETCUR      SETDATE     SETIME
  1698.        WHATDAY     WHATYR      WHATMIN     WHATMO      WHATYR    YRSINCE
  1699.  
  1700.        Some  of the above you may end up putting into the 1st  directory
  1701.        SEBFU1,  such as PRDY, LPT1TO2, PRINT, etc... depending  on  your
  1702.        use of the printer, or maybe you may use the SCROLMSG a lot, then
  1703.        that would go into the directory SEBFU1 .  Set your new PATH such
  1704.        that your environment space looks like :
  1705.  
  1706.        PATH=C:\DOS\LEV1;C:\UTILS\SEBFU1;C:\DOS\LEV2;C:\BAT;
  1707.        C:\UTILS\SEBFU2;C:\DOS\LEV3
  1708.  
  1709.        Now  you can get a better idea of how fast the environment  space
  1710.        can get used up. The above line is about 85 bytes long ! That  85
  1711.        bytes  plus  the bytes necessary for  the  COMSPEC=C:\COMMAND.COM
  1712.        would be over a 110 bytes ! That leave less than 50 bytes, if you
  1713.        are satisfied with the Dos default value of 160 bytes.
  1714.  
  1715.        The  above doesn't include any other paths that you may  want  to
  1716.        add  to the list, such as one to your wordprocessor, one  to  the
  1717.        NORTON  UTILITIES,  or  whatever else you may have.  If  you  are
  1718.        convinced about adding more space for the environment  variables,
  1719.        then be sure to add the line :
  1720.  
  1721.        SHELL=C:\COMMAND.COM /E:nnn C:\ /P
  1722.  
  1723.        The 'nnn' in the above is the number of bytes you want Dos to set
  1724.        aside for the environment variables.  Our suggestion is 1000,  or
  1725.        a  minimum of 500, although more or less are ok,  depending  upon
  1726.        your needs.
  1727.  
  1728.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1729.  
  1730.           by Scanlon Enterprises                         Page 31
  1731.  
  1732.  
  1733.  
  1734.        USING  SEBFU:  Up to this point, we have discussed only  the  Dos
  1735.        internal  commands.   Two of the biggest objections  we  have  to
  1736.        batch  files are the lack of cursor controls and keyboard  input.
  1737.        The  foregoing  does NOT include the DOS external  commands  like
  1738.        FORMAT, which do use user input (but still has no control of  the
  1739.        screen display and cursor). How can keyboard input help ?
  1740.  
  1741.        Let's  use our simplest keyboard input (YN) to demonstrate  in  a
  1742.        batch file the use of keyboard responses.
  1743.  
  1744.        ECHO OFF
  1745.        :FMTLP
  1746.        CLS
  1747.        ECHO Do you really want to Format the disk in Drive A (Y/N) ?
  1748.        YN
  1749.        IF ERRORLEVEL 1 GOTO NOFMT
  1750.        ECHO Formatting disk in drive A
  1751.        FORMAT A: < ans
  1752.        ECHO Format complete !
  1753.        PROMPT $_
  1754.        PROMPT $P$G
  1755.        ECHO Format another disk (Y/N) ?
  1756.        YN
  1757.        IF ERRORLEVEL 1 GOTO NOFMT
  1758.        GOTO FMTLP
  1759.        :NOFMT
  1760.        ECHO Done !
  1761.  
  1762.        In  the  above, we have set up a loop (format loop)  starting  at
  1763.        label  :FMTLP . In our first ECHO command, we asked the  user  if
  1764.        they  want  to  format a disk in drive A .  This is  done,  as  a
  1765.        verify  operation,  in case the user got here  by  mistake,  thus
  1766.        allowing the user to exit without formatting a disk.  The  simple
  1767.        YN on the next line, executes our utility YN.COM which waits  for
  1768.        the  user  to press either a Y or N (upper or  lower  case),  and
  1769.        returns  an ERRORLEVEL of 1 if N was pressed, and 0 if the Y  was
  1770.        pressed.   The program will NOT exit with other  keystrokes,  but
  1771.        instead, will beep if any other key is pressed.
  1772.  
  1773.        The  following  line  tests the ERRORLEVEL set by  YN  .  If  the
  1774.        ERRORLEVEL  is 1 (a no response), then the program will exit  via
  1775.        label  :NOFMT  . However, if the response were yes (Y)  then  the
  1776.        program  cycles to the ECHO statement which displays  'Formatting
  1777.        disk  in drive A ', followed by the actual command to format  the
  1778.        disk in drive A (FORMAT A: < c:\bat\ans).  Whats the '< ans ' for
  1779.        ? Here, we have gotten a little tricky, and are using one of  the
  1780.        Dos redirection commands to send input from the file ANS which is
  1781.        on drive C in directory BAT .  That file contains these lines :
  1782.  
  1783.                                 {blank line}
  1784.                                 {blank line}
  1785.        n
  1786.                                 {blank line}
  1787.  
  1788.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1789.  
  1790.           by Scanlon Enterprises                         Page 32
  1791.  
  1792.  
  1793.  
  1794.        This  pipes the required responses to FORMAT so that  the  format
  1795.        will occur without user intervention. The next two lines are used
  1796.        to  generate  a  CR/LF (a blank line),  with  the  second  prompt
  1797.        command  returning the prompt back to our normal value.  Then  we
  1798.        display  the  message  'Format complete !' and ask  the  user  if
  1799.        another  disk  needs  to be formatted  with  the  string  'Format
  1800.        another disk (Y/N)' and then getting the Y or N response via  our
  1801.        YN.COM  utility. Based on the returned response (ERRORLEVEL),  we
  1802.        either exit via the label :NOFMT or loop thru again via the label
  1803.        :FMTLP .
  1804.  
  1805.        Although  the above is certainly good, it still can be  improved.
  1806.        Below, is an improved version.
  1807.  
  1808.        ECHO OFF
  1809.        :FMTLP
  1810.        CLS
  1811.        ECHO Do you really want to Format the disk in Drive A (Y/N) ?
  1812.        YN
  1813.        IF ERRORLEVEL 1 GOTO NOFMT
  1814.        ECHO Formatting disk in drive A
  1815.        FORMAT A: < ans > NUL
  1816.        IF ERRORLEVE 1 GOTO FMTFAIL
  1817.        ECHO Format complete !
  1818.        PROMPT $_
  1819.        PROMPT $P$G
  1820.        ECHO Format another disk (Y/N) ?
  1821.        YN
  1822.        IF ERRORLEVE 1 GOTO NOFMT
  1823.        GOTO FMTLP
  1824.        :FMTFAIL
  1825.        ECHO Format failure, check disk and drive.
  1826.        ECHO Do you wish to retry (Y/N) ?
  1827.        YN
  1828.        IF NOT ERRORLEVEL 1 GOTO FMTLP
  1829.        :NOFMT
  1830.        ECHO Done !
  1831.  
  1832.        What  have we added ? The line containing the FORMAT command  has
  1833.        an  additional redirection command, the '> NUL', which  redirects
  1834.        the  output of FORMAT to the NUL device.  Whats that ?  The  null
  1835.        device is nothing !  That is, we are sending the output nowhere !
  1836.        This  is  very  useful in circumstances where we  don't  want  to
  1837.        clutter  up the display.  This way, we only have the messages  we
  1838.        want  on  the screen. Also we've added an  additional  ERRORLEVEL
  1839.        test, after the FORMAT command, to check for a successful format.
  1840.        If  the format failed (bad disk, no disk, or whatever),  the  the
  1841.        program  loops  to the label :FMTFAIL where we ask  the  user  to
  1842.        check  the  situation out and enter a Y if He/She wishes  to  try
  1843.        again.  Otherwise we will exit via the label :NOFMT . Notice  the
  1844.        ERRORLEVEL test performed after our call to YN .  We used another
  1845.        Dos feature the NOT command. Used as we did, if the ERRORLEVEL is
  1846.        0, the program loops to :FMTLP and if 1 drops to :NOFMT !
  1847.  
  1848.        Look what we've been able to do by just adding 1 command !
  1849.  
  1850.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1851.  
  1852.           by Scanlon Enterprises                         Page 33
  1853.  
  1854.  
  1855.  
  1856.        Let's  add  another  command.  That's one thing  that  you  can't
  1857.        easily  do  in other programming languages (add  more  commands).
  1858.        Which do we add ?  How about LOCATE ?  Ok, lets add LOCATE to the
  1859.        previous example and see what we can do.
  1860.  
  1861.        ECHO OFF
  1862.        :FMTLP
  1863.        CLS
  1864.        LOCATE 5 5
  1865.        ECHO Do you really want to Format the disk in Drive A (Y/N) ?
  1866.        LOCATE 5 63
  1867.        YN
  1868.        IF ERRORLEVEL 1 GOTO NOFMT
  1869.        LOCATE 7 5
  1870.        ECHO Formatting disk in drive A
  1871.        FORMAT A: < ans > NUL
  1872.        IF ERRORLEVE 1 GOTO FMTFAIL
  1873.        LOCATE 8 5
  1874.        ECHO Format complete !
  1875.        LOCATE 10 5
  1876.        ECHO Format another disk (Y/N) ?
  1877.        LOCATE 10 33
  1878.        YN
  1879.        IF ERRORLEVE 1 GOTO NOFMT
  1880.        GOTO FMTLP
  1881.        :FMTFAIL
  1882.        LOCATE 8 5
  1883.        ECHO Format failure, check disk and drive.
  1884.        LOCATE 9 5
  1885.        ECHO Do you wish to retry (Y/N) ?
  1886.        LOCATE 9 34
  1887.        YN
  1888.        IF NOT ERRORLEVEL 1 GOTO FMTLP
  1889.        :NOFMT
  1890.        LOCATE 15 5
  1891.        ECHO Done !
  1892.  
  1893.        Actually, we really haven't done a whole lot.  What we have done,
  1894.        is  make  the actual display of information a little  nicer.  For
  1895.        instance,  in  the previous version, each time we called  our  YN
  1896.        utility, the cursor would be on a different line, with the above,
  1897.        after executing each echo, we reposition the cursor to the end of
  1898.        the  line.  Pretty neat ! We can improve all this a  little  more
  1899.        without adding any additional commands, by making use of an added
  1900.        feature  of  our YN command. YN allow you to enter  a  string  to
  1901.        display, so using this feature, the batch file now becomes.
  1902.  
  1903.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1904.  
  1905.           by Scanlon Enterprises                         Page 34
  1906.  
  1907.  
  1908.  
  1909.        ECHO OFF
  1910.        :FMTLP
  1911.        CLS
  1912.        LOCATE 5 5
  1913.        YN Do you really want to Format the disk in Drive A (Y/N) ?
  1914.        IF ERRORLEVEL 1 GOTO NOFMT
  1915.        LOCATE 7 5
  1916.        ECHO Formatting disk in drive A
  1917.        FORMAT A: < ans > NUL
  1918.        IF ERRORLEVE 1 GOTO FMTFAIL
  1919.        LOCATE 8 5
  1920.        ECHO Format complete !
  1921.        LOCATE 10 5
  1922.        YN Format another disk (Y/N) ?
  1923.        IF ERRORLEVE 1 GOTO NOFMT
  1924.        GOTO FMTLP
  1925.        :FMTFAIL
  1926.        LOCATE 8 5
  1927.        ECHO Format failure, check disk and drive.
  1928.        LOCATE 9 5
  1929.        YN Do you wish to retry (Y/N) ?
  1930.        IF NOT ERRORLEVEL 1 GOTO FMTLP
  1931.        :NOFMT
  1932.        LOCATE 15 5
  1933.        ECHO Done !
  1934.  
  1935.        We've  made  the batch file significantly shorter.   This  means,
  1936.        that it will execute just a little bit faster.  Each time we call
  1937.        a  command,  it  takes our batch file just  a  little  longer  to
  1938.        execute,  and also takes up more disk space. Since we are  trying
  1939.        to  make this document as generic as possible, we won't  go  into
  1940.        the  additional feature of adding color.  Yes, our YN allows  you
  1941.        to  specify  which color to use when display the  text.  If  this
  1942.        feature  interests you, we suggest you read our file BATCH.DOC  ,
  1943.        which explains each of the commands in our utility set.
  1944.  
  1945.        How  can  we  add to this batch file ?   Let's  add  yet  another
  1946.        command,  the  DSKRDY  command.  This little baby  will  set  the
  1947.        ERRORLEVEL  based  upon  the status of the  selected  drive.  The
  1948.        ERRORLEVEL will be 0 if the drive is ready, and a formatted  disk
  1949.        is installed otherwise, the ERRORLEVEL's returned will be :
  1950.  
  1951.        ERRORLEVEL = 1  drive not ready (door open)
  1952.        ERRORLEVEL = 2  disk in drive is NOT formatted
  1953.        ERRORLEVEL = 3  drive not found
  1954.  
  1955.        For  our demonstration batch file, we really want  the  condition
  1956.        where ERRORLEVEL is a 2 (disk in drive NOT formatted).   Ideally,
  1957.        the user will be formatting a NEW disk.  For those cases the user
  1958.        wants  to  format a used disk, we will prompt  for  verification.
  1959.        Here is the batch file redone to make use of the new command :
  1960.  
  1961.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  1962.  
  1963.           by Scanlon Enterprises                         Page 35
  1964.  
  1965.  
  1966.  
  1967.        ECHO OFF
  1968.        :FMTLP
  1969.        CLS
  1970.        LOCATE 5 5
  1971.        YN Are you ready to Format the disk in Drive A (Y/N) ?
  1972.        IF ERRORLEVEL 1 GOTO NOFMT
  1973.        DSKRDY A:
  1974.        IF ERRORLEVEL 3 GOTO NOTRDY
  1975.        IF ERRORLEVEL 2 GOTO FMTIT
  1976.        IF ERRORLEVEL 1 GOTO NOTRDY
  1977.        CLS
  1978.        LOCATE 5 5
  1979.        ECHO The disk in drive A has data on it, are you sure you
  1980.        LOCATE 5 53
  1981.        YN you want to format it (Y/N) ?
  1982.        IF ERRORLEVEL 1 GOTO NOFMT
  1983.        :FMTIT
  1984.        LOCATE 7 5
  1985.        ECHO Formatting disk in drive A
  1986.        FORMAT A: < ans > NUL
  1987.        IF ERRORLEVE 1 GOTO FMTFAIL
  1988.        LOCATE 8 5
  1989.        ECHO Format complete !
  1990.        LOCATE 10 5
  1991.        YN Format another disk (Y/N) ?
  1992.        IF ERRORLEVE 1 GOTO NOFMT
  1993.        GOTO FMTLP
  1994.        :NOTRDY
  1995.        LOCATE 8 5
  1996.        YN Drive not Ready, try again ?
  1997.        IF ERRORLEVEL 1 GOTO NOFMT
  1998.        GOTO FMTLP
  1999.        :FMTFAIL
  2000.        LOCATE 8 5
  2001.        ECHO Format failure, check disk and drive.
  2002.        LOCATE 9 5
  2003.        YN Do you wish to retry (Y/N) ?
  2004.        IF NOT ERRORLEVEL 1 GOTO FMTLP
  2005.        :NOFMT
  2006.        LOCATE 15 5
  2007.        ECHO Done !
  2008.  
  2009.        Well, how about that, we sure have enhanced this little  utility.
  2010.        Add  this to your library of batch files, and never  worry  again
  2011.        about accidentally formatting a disk with data on it ! But, guess
  2012.        what, we are even going say, that this still is NOT enough.  What
  2013.        can  we  do  to make this even better ?  Easy,  let's  make  this
  2014.        utility allow the user to select which drive to format !  We will
  2015.        do  this  by  adding  the command GKEY to  our  growing  list  of
  2016.        commands.
  2017.  
  2018.        Let's go ahead and rewrite the utility, including the ability  to
  2019.        format either drive A or B .
  2020.  
  2021.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2022.  
  2023.           by Scanlon Enterprises                         Page 36
  2024.  
  2025.  
  2026.  
  2027.        ECHO OFF
  2028.        IF '%1'=='' GOTO GETDRV
  2029.        CLS
  2030.        IF %1==A GOTO FMTLPA
  2031.        IF %1==a GOTO FMTLPA
  2032.        IF %1==B GOTO FMTLPB
  2033.        IF NOT %1==b GOTO GETDRV
  2034.        :FMTLPB
  2035.        LOCATE 5 5
  2036.        YN Are you ready to Format the disk in Drive B (Y/N) ?
  2037.        IF ERRORLEVEL 1 GOTO NOFMT
  2038.        DSKRDY B:
  2039.        IF ERRORLEVEL 3 GOTO NODRV
  2040.        IF ERRORLEVEL 2 GOTO FMTIT
  2041.        IF ERRORLEVEL 1 GOTO NOTRDY
  2042.        CLS
  2043.        LOCATE 5 5
  2044.        ECHO The disk in drive B has data on it, are you sure you
  2045.        LOCATE 5 53
  2046.        YN you want to format it (Y/N) ?
  2047.        IF ERRORLEVEL 1 GOTO NOFMT
  2048.        :FMTITB
  2049.        LOCATE 7 5
  2050.        ECHO Formatting disk in drive B
  2051.        FORMAT B: < c:\bat\ans > NUL      {you may need to change drive}
  2052.        GOTO EFMT
  2053.        :FMTLPA
  2054.        LOCATE 5 5
  2055.        YN Are you ready to Format the disk in Drive A (Y/N) ?
  2056.        IF ERRORLEVEL 1 GOTO NOFMT
  2057.        DSKRDY A:
  2058.        IF ERRORLEVEL 3 GOTO NODRV
  2059.        IF ERRORLEVEL 2 GOTO FMTITA
  2060.        IF ERRORLEVEL 1 GOTO NOTRDY
  2061.        CLS
  2062.        LOCATE 5 5
  2063.        ECHO The disk in drive A has data on it, are you sure you
  2064.        LOCATE 5 53
  2065.        YN you want to format it (Y/N) ?
  2066.        IF ERRORLEVEL 1 GOTO NOFMT
  2067.        :FMTITA
  2068.        LOCATE 7 5
  2069.        ECHO Formatting disk in drive A
  2070.        FORMAT A: < c:\bat\ans > NUL      {you may need to change drive}
  2071.        :EFMT
  2072.        IF ERRORLEVE 1 GOTO FMTFAIL
  2073.        LOCATE 8 5
  2074.        ECHO Format complete !
  2075.        LOCATE 10 5
  2076.        YN Format another disk (Y/N) ?
  2077.        IF ERRORLEVE 1 GOTO NOFMT
  2078.        GOTO FMTLP
  2079.  
  2080.                                   {continues on next page}
  2081.  
  2082.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2083.  
  2084.           by Scanlon Enterprises                         Page 37
  2085.  
  2086.  
  2087.  
  2088.                                   {continued from page 36}
  2089.        :NODRV
  2090.        LOCATE 8 5
  2091.        ECHO The drive you selected to format does not exist,
  2092.        LOCATE 9 5
  2093.        ECHO Please select the other drive.
  2094.        :GETDRV
  2095.        LOCATE 12 5
  2096.        ECHO Enter a (1) to format drive A or a (2) to format drive B
  2097.        LOCATE 13 5
  2098.        ECHO Your choice (1 or 2 or 0 to abort) ?
  2099.        LOCATE 13 23
  2100.        GKEY 012
  2101.        IF ERRORLEVEL 2 GOTO FMTLPB
  2102.        IF ERRORLEVEL 1 GOTO FMTLPA
  2103.        GOTO NOFMT
  2104.        :NOTRDY
  2105.        LOCATE 8 5
  2106.        YN Drive not Ready, try again ?
  2107.        IF ERRORLEVEL 1 GOTO NOFMT
  2108.        GOTO FMTLP
  2109.        :FMTFAIL
  2110.        LOCATE 8 5
  2111.        ECHO Format failure, check disk and drive.
  2112.        LOCATE 9 5
  2113.        YN Do you wish to retry (Y/N) ?
  2114.        IF NOT ERRORLEVEL 1 GOTO FMTLP
  2115.        :NOFMT
  2116.        LOCATE 15 5
  2117.        ECHO Done !
  2118.  
  2119.        You  can try this great new utility, and you won't even  have  to
  2120.        type it in.  We have placed this batch file on this disk, and  we
  2121.        call  it FMT.BAT . To use, just enter FMT d  where d is either  A
  2122.        or  B (upper or lower case), or just enter FMT, and you  will  be
  2123.        prompted for the drive. How's that for a neat utility ?  NOTICE :
  2124.        there are 2 lines above that may need to be edited, they are  the
  2125.        lines  with the string '{you may have to change drive}'  appended
  2126.        at the ends. What this means is, for instance, you may have these
  2127.        utilities on drive A.
  2128.  
  2129.        For  those  of  you who have single drive  machines,  we  haven't
  2130.        forgotten  you.  This  disk also contains  a  batch  file  called
  2131.        SFMT.BAT  , which is a single disk version of the  utility.  This
  2132.        version  won't ask you which drive to format, but will detect  if
  2133.        you have a previously formatted disk installed.
  2134.  
  2135.        We  suggest  to  all of you (especially those  with  only  floppy
  2136.        drives) to place these utilities on a Ram Disk while running  the
  2137.        utility. If you do so, the utility will run a lot faster, even on
  2138.        hard disk systems.
  2139.  
  2140.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2141.  
  2142.           by Scanlon Enterprises                         Page 38
  2143.  
  2144.  
  2145.  
  2146.        Here  is  a  short batch file to use  prior  to  executing  ether
  2147.        FMT.BAT or SFMT.BAT , for those of you with a Ram Disk installed.
  2148.  
  2149.        ECHO OFF
  2150.        CLS
  2151.        LOCATE 5 5
  2152.        ECHO This utility will copy the batch file FMT or SFMT to your
  2153.        LOCATE 6 5
  2154.        ECHO Ram disk, along with all of the necessary Batch File Utils
  2155.        LOCATE 7 5
  2156.        ECHO required by the batch file.
  2157.        LOCATE 9 5
  2158.        ECHO You must be logged onto the drive and directory where the
  2159.        LOCATE 10 5
  2160.        ECHO utilities are prior to running this.
  2161.        LOCATE 12 5
  2162.        YN Are you running a single drive system (Y/N) ?
  2163.        IF ERRORLEVEL 1 GOTO INSTFMT
  2164.        :INSTSFMT
  2165.        CLS
  2166.        LOCATE 5 5
  2167.        YN Are you ready for the transfer ?
  2168.        IF ERRORLEVEL 1 GOTO NODO
  2169.        MD D:BAT
  2170.        IF ERRORLEVEL 1 GOTO NODSK
  2171.        CD D:BAT
  2172.        IF NOT EXIST SFMTD.BAT GOTO NOTFND
  2173.        COPY SFMT.BAT D:FMT.BAT
  2174.        GOTO TREST
  2175.        :INSTFMT
  2176.        CLS
  2177.        YN Are you ready for the transfer
  2178.        IF ERRORLEVEL 1 GOTO EXIT
  2179.        MD D:BAT
  2180.        IF ERRORLEVEL 1 GOTO NODSK
  2181.        CD D:BAT
  2182.        IF NOT EXIST FMTD.BAT GOTO NOTFND
  2183.        COPY FMT.BAT D:FMT.BAT
  2184.        :TREST
  2185.        IF NOT EXIST LOCATE.COM GOTO NOFND
  2186.        COPY LOCATE.COM D:                  {We assume your Ram disk to
  2187.        IF NOT EXIST YN.COM GOTO NOFND        be drive D, if this is not
  2188.        COPY YN.COM D:                        the case, change the D to
  2189.        IF NOT EXIST GKEY.COM GOTO NOFND      whatever drive letter you
  2190.        COPY GKEY.COM D:                      your Ram disk is}
  2191.        IF NOT EXIST DSKRDY.COM GOTO NOFND
  2192.        COPY DSKRDY.COM D:
  2193.        IF NOT EXIST ANS GOTO NOFND
  2194.        COPY ANS D:
  2195.        :GOTALL
  2196.        LOCATE 7 5
  2197.        ECHO All files transferred !
  2198.        GOTO EXIT
  2199.  
  2200.                                               {continues next page}
  2201.  
  2202.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2203.  
  2204.           by Scanlon Enterprises                         Page 39
  2205.  
  2206.  
  2207.  
  2208.                                             {continued from page 38}
  2209.        :NOTFND
  2210.        LOCATE 7 5
  2211.        ECHO Files were NOT transferred !
  2212.        GOTO EXIT
  2213.        :NODSK
  2214.        ECHO Ram disk NOT found !
  2215.        GOTO NOTFND
  2216.        :EXIT
  2217.  
  2218.        Notice  : We actually have a batch file (2 actually) for  use  on
  2219.        Ram disks, they are SFMTD and FMTD , one for single drive systems
  2220.        and  one for 2 drive systems. By the way, you need NOT enter  the
  2221.        above batch file, it's also on your disk.  The batch file name is
  2222.        XFRAM.BAT . To use, just log onto our disk and enter XFRAM at the
  2223.        Dos prompt.
  2224.  
  2225.        Here's a test for you, look up our batch file commands BEEP, CUON
  2226.        and COFF. Add these to the last 2 batch files, and try to improve
  2227.        them.  If you do improve the above 2 utilities, and send them  to
  2228.        us,  and  we add them to our utility disk, we will send  you  the
  2229.        upgrade FREE, and you will get credit (in the documentation)  for
  2230.        making  the  batch  files. You might say, that  this  is  like  a
  2231.        contest. Good Luck !
  2232.  
  2233.        Let's  add  a  new command to our list of  commands.   WRITE  was
  2234.        created to enhance displaying text on the display. With WRITE, it
  2235.        now  becomes easy to display a blank line, to merge 2  (or  more)
  2236.        lines  together (to form one long line) and for those with  color
  2237.        monitors, to add a little color to their life.
  2238.  
  2239.        We  already have 2 great utilities, so why not another ? Many  of
  2240.        you  need to copy files from disk to disk, so let's make  a  Wild
  2241.        copy  utility. We'll start off by giving an over view of what  we
  2242.        expect  it  to  do, then we will show  the  listing  and  finally
  2243.        explain it in a line by line basis.
  2244.  
  2245.        This utility will have what is called a command line, by which we
  2246.        mean,  that you will enter parameters after entering the name  of
  2247.        the  batch file (on the same line), and that the batch file  will
  2248.        act upon those parameters. This utility will be for those with  2
  2249.        drives  (A  and  B),  but  it  may  be  modified  for   different
  2250.        combinations,  or even to work across several drives, such  as  a
  2251.        hard disk and 2 floppy drives. This batch file will allow you  to
  2252.        pass  it  several parameters, with the 1st  parameter  specifying
  2253.        which  drive to copy from.  If for instance, you enter the  batch
  2254.        file  with A as the first parameter, it will be assumed that  you
  2255.        want  to  copy  the files to drive B .  We will  call  this  file
  2256.        CPY.BAT .  Thus, entering the line :
  2257.  
  2258.        CPY A TEST.BAT TEST.DAT LOCATE.COM GKEY.COM YN.COM WRITE.COM
  2259.  
  2260.        Would  copy the files TEST.BAT, TEST.DAT,  LOCATE.COM,  GKEY.COM,
  2261.        YN.COM and WRITE.COM from drive A to drive B .
  2262.  
  2263.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2264.  
  2265.           by Scanlon Enterprises                         Page 40
  2266.  
  2267.  
  2268.  
  2269.                                                {CPY.BAT}
  2270.  
  2271.        ECHO OFF
  2272.        CLS
  2273.        IF '%1'=='' GOTO BADXIT            {test if drive was selected}
  2274.        IF %1==A SET SOURCE=A              {source = A ?}
  2275.        IF %1==a SET SOURCE=A
  2276.        IF %1==B SET SOURCE=B              {source = B ?}
  2277.        IF NOT %1==b GOTO BADXIT
  2278.        IF %SOURCE%==A SET DEST=B          {set destination based on
  2279.        IF %SOURCE%==B SET DEST=A            source}
  2280.        LOCATE 5 5
  2281.        WRITE ~~Transfer files from
  2282.        IF %DEST%==A WRITE ~~B
  2283.        IF %DEST%==B WRITE ~~A
  2284.        WRITE ~~to
  2285.        IF %DEST%==A WRITE ~~A
  2286.        IF %DEST%==B WRITE ~~B
  2287.        YN , correct ?
  2288.        IF ERRORLEVEL 1 GOTO EXIT
  2289.        CLS
  2290.        LOCATE 5 5
  2291.        WRITE Transfer started.
  2292.        WRITE
  2293.        SHIFT
  2294.        SHIFT
  2295.        :CPYLP
  2296.        SHIFT
  2297.        IF '%1'=='' GOTO DONE
  2298.        COPY %SOURCE%:%1 %DEST% > NUL      {don't show anything
  2299.        IF ERRORLEVEL 1 GOTO CPYERR
  2300.        WRITE ~~Transferred
  2301.        ECHO %1
  2302.        GOTO CPYLP
  2303.        :DONE
  2304.        WRITE
  2305.        WRITE Transfer completed
  2306.        GOTO EXIT
  2307.        :CPYERR
  2308.        WRITE
  2309.        WRITE Transfer process failure.
  2310.        WRITE
  2311.        WRITE ~~Problem occurred during Copy of
  2312.        ECHO %1
  2313.        GOTO EXIT
  2314.        :BADXIT
  2315.        WRITE
  2316.        WRITE Transfer utility aborted, bad entry source drive.
  2317.        :EXIT
  2318.        SET SOURCE=
  2319.        SET DEST=
  2320.  
  2321.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2322.  
  2323.           by Scanlon Enterprises                         Page 41
  2324.  
  2325.  
  2326.  
  2327.        Another  challenge ! Make a version of this with more  bells  and
  2328.        whistles,   and  allow  for  more  than  the  above  source   and
  2329.        destinations.  Send us your entry, if chosen, your entry will  be
  2330.        included  in  our next release of SEBFU, and you will  receive  a
  2331.        FREE upgrade.
  2332.  
  2333.        OK, how does this work ? We start off by setting the 2  variables
  2334.        DEST  and SOURCE to equal the destination and source  drives.  If
  2335.        the  passed  source drive is NOT valid, we just  exit.  Next,  we
  2336.        display a message to verify that the source and destinations  are
  2337.        correct. If the user responds to the YN function with a N we exit
  2338.        the program without any other fanfare. If the answer is yes, then
  2339.        we precede with the copying process.
  2340.  
  2341.        We pass each file name, as we find them, to the COPY command  via
  2342.        the variable %1, while specifying both the destination and source
  2343.        via the two variables SOURCE and DEST .  We loop thru label CPYLP
  2344.        until  we  don't find a parameter, announcing a  successful  copy
  2345.        process, or exiting with an error message via label CPYERR .
  2346.  
  2347.        Possible  improvements  include  prompting  for  the  source  and
  2348.        destination, allowing a different source and destination for each
  2349.        occurrence, allowing a switch for verification, proceeding to the
  2350.        next  entry even if a failure occurs. All of  these  enhancements
  2351.        can  be made, and should none of you write in a good version  for
  2352.        us, we'll write one our selves.
  2353.  
  2354.        To  aid in speeding up screen displays, we have  created  WRITEF,
  2355.        which  will  display an entire file on the  display  device.  Why
  2356.        would we do that ?  Each time you make a call to Dos to execute a
  2357.        command, a file must be read in, then the program must  interpret
  2358.        the  command  line (if there is one), then perform  the  assigned
  2359.        task.  Our single line WRITE command, although very  useful,  has
  2360.        the  same disadvantage as the Dos ECHO command, in that for  each
  2361.        call to it, WRITE must be read into memory, probably from a disk,
  2362.        then  it  must perform its task. Usually, we could use  the  TYPE
  2363.        command to display a file, but TYPE has some draw-backs as well.
  2364.  
  2365.        One of the disadvantages to using TYPE is that all lines are left
  2366.        justified, and if you have ANSI.SYS installed, you are allowed to
  2367.        use  only the existing set color. If you doubt it, use our  COLOR
  2368.        command to set the color to, say green on black, then use our CLR
  2369.        command to clear the display to white on blue. Next position  the
  2370.        cursor  to  the top of the display, and use the TYPE  command  to
  2371.        display a short file. If ANSI.SYS is installed, the file will  be
  2372.        displayed  in green on black, and if it's not, the file  will  be
  2373.        displayed  in  white on blue. This can easily be done  using  the
  2374.        following lines in a batch file.
  2375.  
  2376.        ECHO OFF
  2377.        COLOR 0 2
  2378.        CLR 1 1 25 80
  2379.        LOCATE 1 1
  2380.        TYPE {file} enter the file name you want to display
  2381.  
  2382.            B A T C H    F I L E    T U T O R    Ver. 1.7  (SEBFT)
  2383.  
  2384.           by Scanlon Enterprises                         Page 42
  2385.  
  2386.  
  2387.  
  2388.        Now  try  the same thing with our  WRITEF  command,  substituting
  2389.        WRITE for the TYPE in the above lines. WRITEF also allows you  to
  2390.        set  the left margin. To do this, use our LOCATE command. In  the
  2391.        above,  substitute LOCATE 1 5 for the line LOCATE 1 1, and  watch
  2392.        the results.  Each line will now start on column 5.
  2393.  
  2394.        What  do  you do when you want to display a character,  that  you
  2395.        just can't get your word processor to let you enter ? We've fixed
  2396.        that possibility by supplying you with the command STRING,  which
  2397.        not  only allows you to display any character in the range  of  0
  2398.        thru 255, but also to display multiple values of that  character,
  2399.        in  what  ever  color  you want. By  using  the  /P  switch,  the
  2400.        character can also be printer.
  2401.  
  2402.        Want to make music, or just some noise, well, we give you  SOUND.
  2403.        This will sound the speaker for a specified period of time and at
  2404.        a specified tone, similar to the BASIC SOUND statement. This  can
  2405.        be  used to make a noise announcing the end of a  command  cycle,
  2406.        announce  errors or just about anything. For those of  you  using
  2407.        the printer in conjunction with batch files, we have supplied you
  2408.        with  PRDY,  which  sets an ERRORLEVEL  based  upon  the  printer
  2409.        status, IE.... and ERRORLEVEL of 0 means everything is OK.
  2410.  
  2411.        Now,  what else have we got in our little bag of tricks ?   Well,
  2412.        we  have  the PRINT command, which does for printing  what  WRITE
  2413.        does for the display (no color), we have PRINTF, which prints  an
  2414.        entire  file, PRINTC which prints any ascii character, great  for
  2415.        sending  printer  set  up  information.   There  are  many   more
  2416.        commands,  we'd like you to read the Doc file  BATCH.DOC.   Don't
  2417.        forget to send in those suggestions.
  2418.  
  2419.        Well,  we  hope  that  this tutorial has been  of  help  and  was
  2420.        informative.   If you like, why not run our demo ?  There  are  2
  2421.        versions of the demo, DEMOM for monochrome systems and DEMOC  for
  2422.        color  systems. Just enter DEMOM or DEMOC at the Dos prompt.  The
  2423.        color  version is a little more flashy, due to the extensive  use
  2424.        of colors, but both demonstrate our utilities very well.
  2425.  
  2426.        Anyone  creating  a unique or interesting batch  file  using  our
  2427.        utilities may send them to us, and if found to be worthy, will be
  2428.        placed  in  our  batch file library to be included  in  a  future
  2429.        release and will have their names included in our documentation.
  2430.  
  2431.        Thank you for using the Batch File Utilities by :
  2432.  
  2433.                                      Scanlon Enterprises
  2434.                                      38354 17th St. E #C
  2435.                                      Palmdale, CA  93550
  2436.